My Requirement is to Add some header in a interceptor on all requests coming via RestTemplate so I am using a ClientHttpRequestInterceptor But I also need to add all params encoaded in header but in this interceptor we get HTTPREQUEST Object which do not have any way to get Params
I have tried using HandlerInterceptorAdapter which gives me HttpServletRequest to do all I need but I can' set this interceptor in restTemplate.setInterceptors
public class RequestResponseInterceptor implements ClientHttpRequestInterceptor {
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException {
// Add additional headers
addRequestHeaders(request);
return execution.execute(request, body);
}
but in addRequestHeaders how to get param from request ?