HttpResponseMessage.Builder Interface

public interface Builder

A builder to create an instance of HttpResponseMessage

Method Summary

Modifier and Type Method and Description
HttpResponseMessage.Builder body(Object body)

Sets the body of the HTTP response.

HttpResponseMessage build()

Creates an instance of HttpMessageResponse with the values configured in this builder.

HttpResponseMessage.Builder header(String key, String value)

Adds a (key, value) header to the response.

HttpResponseMessage.Builder status(HttpStatusType status)

Sets the status code to be used in the HttpResponseMessage object.

You can provide standard HTTP Status using enum values from HttpStatus, or you can create a custom status code using custom(final int code).

Method Details

body

public Builder body(Object body)

Sets the body of the HTTP response.

Parameters:

body - The body of the HTTP response

Returns:

this builder

build

public HttpResponseMessage build()

Creates an instance of HttpMessageResponse with the values configured in this builder.

Returns:

an HttpMessageResponse object

header

public Builder header(String key, String value)

Adds a (key, value) header to the response.

Parameters:

key - The key of the header value.
value - The value of the header value.

Returns:

this builder

status

public Builder status(HttpStatusType status)

Sets the status code to be used in the HttpResponseMessage object.

You can provide standard HTTP Status using enum values from HttpStatus, or you can create a custom status code using custom(final int code).

Parameters:

status - An HTTP status code representing the outcome of the HTTP request.

Returns:

this builder

Applies to