0
votes

I have a problem statement where I need to pass HttpServletRequest from one controller to another so that I can extract the Authorization header in another controller. Any lead appreciated please let me know how I can pass it through feign client API request and How I accept it in another controller.

Thanks in advance.

1

1 Answers

0
votes

This is the simple example that how you will pass the Httprequest from one controller to other controller.

HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);

MultiValueMap<String, Object> form = new LinkedMultiValueMap<>();
form.add("name", request.getParameter("name"));
form.add("abc", request.getParameter("abc"));
form.add("xyz", request.getParameter("xyz"));

HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(form, httpHeaders);
restTemplate.postForEntity("http:localhost:8080/save", requestEntity, String.class);