Perhaps option with HttpServletRequest
will suit you?
@RequestMapping("/foo")
@CrossOrigin(maxAge = 3600)
@RestController
public class WebHandler {
@RequestMapping("/bar")
public void bar(HttpServletRequest request) throws Exception {
BufferedReader reader = request.getReader();
String body = reader.lines().collect(Collectors.joining("\n"));
System.out.println(body);
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String headerName = headerNames.nextElement();
System.out.println(headerName + ": " + request.getHeader(headerName));
}
}
}
You can also see for yourself what other information you can get from there.
If you need only body and headers, you can make it so:
@RequestMapping("/bar")
public void bar(@RequestHeader Map<String, String> headers,
@RequestBody String body) {
System.out.println(body);
System.out.println(headers);
}