{title:'HTTP Part APIs', created:'9.0.0'}

Request HTTP parts can also be retrieved programmatically through the following classes that can be passed in as parameters or access through {@link oajr.RestRequest} bean:

Example:

| @RestPost(...) | 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").as(UUID.class).get(); | | // Get a header as a standard HTTP part. | ContentType contentType = headers.get(ContentType.class).orElse(ContentType.TEXT_XML); | }

Built in to these APIs are various convenience methods such as converting parts to different types or inline fluent assertions:

Example:

| // Inline fluent assertion and retrieval. | String foo = request | .getHeader("Foo") | .assertString().contains("bar") | .get();