Package com.linecorp.armeria.common
Class HttpResponseBuilder
java.lang.Object
com.linecorp.armeria.common.HttpResponseBuilder
Builds a new
HttpResponse
.-
Method Summary
Modifier and TypeMethodDescriptionSets 502 Bad Gateway to the status of this response.Sets 400 Bad Request to the status of this response.build()
Builds the response.Sets the content for this response.Sets the content for this response.content
(MediaType contentType, CharSequence content) Sets the content for this response.Sets the content for this response.Sets the content for this response.Sets thePublisher
for this response.Sets the content as UTF_8 for this response.Sets the content as UTF_8 for this response.contentJson
(Object content) Sets the content for this response.created()
Sets 201 Created to the status of this response.Sets 403 Forbidden to the status of this response.header
(CharSequence name, Object value) Adds a header to this response.headers
(Iterable<? extends Map.Entry<? extends CharSequence, String>> headers) Adds multiple headers to this response.Sets 500 Internal Server Error to the status of this response.Sets 301 Moved Permanently to the status of this response.notFound()
Sets 404 Not Found to the status of this response.ok()
Sets 200 OK to the status of this response.status
(int statusCode) Sets the status for this response.status
(HttpStatus status) Sets the status for this response.trailers
(Iterable<? extends Map.Entry<? extends CharSequence, String>> trailers) Adds HTTP trailers to this response.Sets 401 Unauthorized to the status of this response.
-
Method Details
-
status
Sets the status for this response. -
status
Sets the status for this response. -
ok
Sets 200 OK to the status of this response. -
created
Sets 201 Created to the status of this response. -
movedPermanently
Sets 301 Moved Permanently to the status of this response. -
badRequest
Sets 400 Bad Request to the status of this response. -
unauthorized
Sets 401 Unauthorized to the status of this response. -
forbidden
Sets 403 Forbidden to the status of this response. -
notFound
Sets 404 Not Found to the status of this response. -
internalServerError
Sets 500 Internal Server Error to the status of this response. -
badGateway
Sets 502 Bad Gateway to the status of this response. -
content
Sets the content as UTF_8 for this response. -
content
Sets the content for this response. -
content
Sets the content for this response. -
content
Sets the content as UTF_8 for this response. Thecontent
is formatted byString.format(Locale, String, Object...)
with English locale. -
content
@FormatMethod public HttpResponseBuilder content(MediaType contentType, @FormatString String format, Object... content) Sets the content for this response. Thecontent
is formatted byString.format(Locale, String, Object...)
with English locale. -
content
Sets the content for this response. Thecontent
will be wrapped usingHttpData.wrap(byte[])
, so any changes made tocontent
will be reflected in the response. -
content
Sets the content for this response. -
content
public HttpResponseBuilder content(MediaType contentType, org.reactivestreams.Publisher<? extends HttpData> content) Sets thePublisher
for this response. -
contentJson
Sets the content for this response. Thecontent
is converted into JSON format using the defaultObjectMapper
. -
header
Adds a header to this response. For example:HttpResponse.builder() .ok() .content("Hello, Armeria") .header("Server", "foo") .build();
-
headers
public HttpResponseBuilder headers(Iterable<? extends Map.Entry<? extends CharSequence, String>> headers) Adds multiple headers to this response. For example:HttpResponse.builder() .ok() .content("Hello, Armeria") .headers(HttpHeaders.of("x-test-header", "foo", "Server", "baz")) .build();
- See Also:
-
trailers
public HttpResponseBuilder trailers(Iterable<? extends Map.Entry<? extends CharSequence, String>> trailers) Adds HTTP trailers to this response. -
build
Builds the response.
-