RequestInterceptor FeignClient header

直接上代码,不用解释,你懂的。。
import org.springframework.context.annotation.Configuration;
import feign.RequestInterceptor;
import feign.RequestTemplate;
@Configuration
public class MyRequestInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
 
  
/*   Request request = requestTemplate.request();
   String url = request.url();
   System.out.println("ttttttttttttttttttttt=================="+url);
   if(url.startsWith("/sec/apply"))return;
   String s = testService.test();
   System.out.println("s:"+s);*/
requestTemplate.header( "aaa", "8888");//全局,用于一些公共的头 }

}

//以下这个是用于个别的头

@RequestMapping(value="/sec/check",method= RequestMethod.POST)

public ResultObject check1(@RequestParam("busi") String busi,@RequestParam("seqid")UUID seqid,@RequestHeader(name="bbb",required = false)String bbb);

你可能感兴趣的:(spring,boot,JAVA)