I am trying to achieve the following.
Read a custom header and its value from Request:
name: username
Now, on response, I would like to return the same header name:value
pair in HTTP response.
I am using Jersey 2.0 implementation of JAX-RS webservice.
When I send the request URL Http://localhost/test/
, the request headers are also passed (for the time being, though Firefox plugin - hardcoding them).
On receiving the request for that URL, the following method is invoked:
@GET
@Produces(MediaType.APPLICATION_JSON)
public UserClass getValues(@Context HttpHeaders header) {
MultivaluedMap<String, String> headerParams = header.getRequestHeaders();
String userKey = "name";
headerParams.get(userKey);
// ...
return user_object;
}
How may I achieve this? Any pointers would be great!