RequestHeaders

The {@link oajr.RequestHeaders} object is the API for accessing the headers of an HTTP request. It can be accessed by passing it as a parameter on your REST Java method:

@RestMethod(...) public Object myMethod(RequestHeaders headers) {...}

##### Example:

@RestMethod(...) public Object myMethod(RequestHeaders headers) { // Add a default value. headers.addDefault("ETag", DEFAULT_UUID); // Get a header value as a POJO. UUID etag = headers.get("ETag", UUID.class); // Get a standard header. CacheControl = headers.getCacheControl(); }

Some important methods on this class are:

- {@link oajr.RequestHeaders} extends TreeMap<String,String[]>
  - {@link oajr.RequestHeaders#get(String,Class) get(String,Class)} - Get header value converted to a POJO.
  - {@link oajr.RequestHeaders#get(String,Type,Type...) get(String,Type,Type)} - Get header value converted to a map or collection of POJOs.
  - {@link oajr.RequestHeaders#getString(String,String) getString(String,String)} - Get header value as a simple string.
  - {@link oajr.RequestHeaders#getInt(String,int) getInt(String,int)} - Get header value as an integer.
  - {@link oajr.RequestHeaders#getBoolean(String,boolean) getBoolean(String,boolean)} - Get header value as a boolean.
  - {@link oajr.RequestHeaders#addDefault(String,Object) addDefault(String,Object)} - Programmatically set a default value for a header.

- {@link oaj.http.annotation.Header}