I'm using FeignClient to call service and a RequestInterceptor to add a header, no body change, but it still convert GET to POST. Is there an alternative way to fix this other than using httpclient as backend of Feign?
@FeignClient(name = "admin", url = "${feign.client.config.admin.url:}")
public interface AdminService {
@RequestMapping(value = "/api/users/{username:.+}", method = RequestMethod.GET)
User getUser(@PathVariable("username") String username, @RequestParam("appName") String appName);
}
@Bean
public RequestInterceptor requestInterceptor() {
return requestTemplate -> {
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
HttpServletRequest servletRequest = ((ServletRequestAttributes) requestAttributes).getRequest();
String auth = servletRequest.getHeader("Authorization");
if (StringUtils.isNotBlank(auth)) {
requestTemplate.header("Authorization", servletRequest.getHeader("Authorization"));
}
};
}
After debugging and I found that it puts my "@PathVariable String username" into body which seems the reason of this happening.
Comment From: spencergibb
I think this may duplicate #123
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.