I am using Spring Restful web service and having the request body with the request header, as shown below:
@RequestMapping(value = "/mykey", method = RequestMethod.POST, consumes="applicaton/json")
public ResponseEntity<String> getData(@RequestBody String body, @RequestHeader("Auth") String authorization) {
try {
....
} catch (Exception e) {
....
}
}
I want to pass another additional request header called "X-MyHeader". How to specify this optional request header in Spring rest service?
Also, how to pass this value in the response header? Thank!
UPDATE: I just discovered that I can set require = false in the request header, so that one problem is resolved. Now the only problem remains how to set the title in the response
source
share