Package com.linecorp.armeria.common
Class AbstractHttpRequestBuilder
java.lang.Object
com.linecorp.armeria.common.AbstractHttpMessageBuilder
com.linecorp.armeria.common.AbstractHttpRequestBuilder
- All Implemented Interfaces:
HttpMessageSetters
,HttpRequestSetters
,PathAndQueryParamSetters
,RequestMethodSetters
- Direct Known Subclasses:
HttpRequestBuilder
,WebClientRequestPreparation
public abstract class AbstractHttpRequestBuilder
extends AbstractHttpMessageBuilder
implements HttpRequestSetters
Builds a new
HttpRequest
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final HttpRequest
Creates a newHttpRequest
.Sets the content for this message.Sets the content for this message.content
(MediaType contentType, CharSequence content) Sets the content for this message.Sets the content for this message.Sets the content for this message.Sets thePublisher
for this message.Sets the content as UTF-8 for this message.Sets the content as UTF-8 for this message.Sets thePublisher
for this message.contentJson
(Object content) Sets the content for this message.Sets a cookie for this request.Sets multiple cookies for this request.Sets DELETE method and path.Disables path parameters substitution.Sets GET method and path.Sets HEAD method and path.header
(CharSequence name, Object value) Adds a header for this message.headers
(Iterable<? extends Map.Entry<? extends CharSequence, String>> headers) Adds multiple headers for this message.method
(HttpMethod method) Sets the method for this request.Sets OPTIONS method and path.Sets PATCH method and path.Sets the path for this request.Sets a path param for this request.pathParams
(Map<String, ?> pathParams) Sets multiple path params for this request.Sets POST method and path.Sets PUT method and path.queryParam
(String name, Object value) Adds a query param for this request.queryParams
(Iterable<? extends Map.Entry<? extends String, String>> queryParams) Adds multiple query params for this request.Sets TRACE method and path.trailers
(Iterable<? extends Map.Entry<? extends CharSequence, String>> trailers) Adds HTTP trailers for this message.Methods inherited from class com.linecorp.armeria.common.AbstractHttpMessageBuilder
publisher, trailer
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.linecorp.armeria.common.HttpMessageSetters
trailer
-
Constructor Details
-
AbstractHttpRequestBuilder
public AbstractHttpRequestBuilder()
-
-
Method Details
-
get
Description copied from interface:RequestMethodSetters
Sets GET method and path.- Specified by:
get
in interfaceRequestMethodSetters
-
post
Description copied from interface:RequestMethodSetters
Sets POST method and path.- Specified by:
post
in interfaceRequestMethodSetters
-
put
Description copied from interface:RequestMethodSetters
Sets PUT method and path.- Specified by:
put
in interfaceRequestMethodSetters
-
delete
Description copied from interface:RequestMethodSetters
Sets DELETE method and path.- Specified by:
delete
in interfaceRequestMethodSetters
-
patch
Description copied from interface:RequestMethodSetters
Sets PATCH method and path.- Specified by:
patch
in interfaceRequestMethodSetters
-
options
Description copied from interface:RequestMethodSetters
Sets OPTIONS method and path.- Specified by:
options
in interfaceRequestMethodSetters
-
head
Description copied from interface:RequestMethodSetters
Sets HEAD method and path.- Specified by:
head
in interfaceRequestMethodSetters
-
trace
Description copied from interface:RequestMethodSetters
Sets TRACE method and path.- Specified by:
trace
in interfaceRequestMethodSetters
-
method
Description copied from interface:RequestMethodSetters
Sets the method for this request.- Specified by:
method
in interfaceRequestMethodSetters
- See Also:
-
path
Description copied from interface:RequestMethodSetters
Sets the path for this request.- Specified by:
path
in interfaceRequestMethodSetters
-
content
Description copied from interface:HttpMessageSetters
Sets the content as UTF-8 for this message.- Specified by:
content
in interfaceHttpMessageSetters
- Specified by:
content
in interfaceHttpRequestSetters
- Overrides:
content
in classAbstractHttpMessageBuilder
-
content
Description copied from interface:HttpMessageSetters
Sets the content for this message.- Specified by:
content
in interfaceHttpMessageSetters
- Specified by:
content
in interfaceHttpRequestSetters
- Overrides:
content
in classAbstractHttpMessageBuilder
-
content
Description copied from interface:HttpMessageSetters
Sets the content for this message.- Specified by:
content
in interfaceHttpMessageSetters
- Specified by:
content
in interfaceHttpRequestSetters
- Overrides:
content
in classAbstractHttpMessageBuilder
-
content
@FormatMethod public AbstractHttpRequestBuilder content(@FormatString String format, Object... content) Description copied from interface:HttpMessageSetters
Sets the content as UTF-8 for this message. Thecontent
is formatted byString.format(Locale, String, Object...)
with English locale.- Specified by:
content
in interfaceHttpMessageSetters
- Specified by:
content
in interfaceHttpRequestSetters
- Overrides:
content
in classAbstractHttpMessageBuilder
-
content
@FormatMethod public AbstractHttpRequestBuilder content(MediaType contentType, @FormatString String format, Object... content) Description copied from interface:HttpMessageSetters
Sets the content for this message. Thecontent
is formatted byString.format(Locale, String, Object...)
with English locale.- Specified by:
content
in interfaceHttpMessageSetters
- Specified by:
content
in interfaceHttpRequestSetters
- Overrides:
content
in classAbstractHttpMessageBuilder
-
content
Description copied from interface:HttpMessageSetters
Sets the content for this message. Thecontent
will be wrapped usingHttpData.wrap(byte[])
, so any changes made tocontent
will be reflected in the request.- Specified by:
content
in interfaceHttpMessageSetters
- Specified by:
content
in interfaceHttpRequestSetters
- Overrides:
content
in classAbstractHttpMessageBuilder
-
content
Description copied from interface:HttpMessageSetters
Sets the content for this message.- Specified by:
content
in interfaceHttpMessageSetters
- Specified by:
content
in interfaceHttpRequestSetters
- Overrides:
content
in classAbstractHttpMessageBuilder
-
content
public AbstractHttpRequestBuilder content(org.reactivestreams.Publisher<? extends HttpData> content) Description copied from interface:HttpMessageSetters
Sets thePublisher
for this message.- Specified by:
content
in interfaceHttpMessageSetters
- Specified by:
content
in interfaceHttpRequestSetters
- Overrides:
content
in classAbstractHttpMessageBuilder
-
content
public AbstractHttpRequestBuilder content(MediaType contentType, org.reactivestreams.Publisher<? extends HttpData> content) Description copied from interface:HttpMessageSetters
Sets thePublisher
for this message.- Specified by:
content
in interfaceHttpMessageSetters
- Specified by:
content
in interfaceHttpRequestSetters
- Overrides:
content
in classAbstractHttpMessageBuilder
-
contentJson
Description copied from interface:HttpMessageSetters
Sets the content for this message. Thecontent
is converted into JSON format using the defaultObjectMapper
.- Specified by:
contentJson
in interfaceHttpMessageSetters
- Specified by:
contentJson
in interfaceHttpRequestSetters
- Overrides:
contentJson
in classAbstractHttpMessageBuilder
-
header
Description copied from interface:HttpMessageSetters
Adds a header for this message.- Specified by:
header
in interfaceHttpMessageSetters
- Specified by:
header
in interfaceHttpRequestSetters
- Overrides:
header
in classAbstractHttpMessageBuilder
-
headers
public AbstractHttpRequestBuilder headers(Iterable<? extends Map.Entry<? extends CharSequence, String>> headers) Description copied from interface:HttpMessageSetters
Adds multiple headers for this message.- Specified by:
headers
in interfaceHttpMessageSetters
- Specified by:
headers
in interfaceHttpRequestSetters
- Overrides:
headers
in classAbstractHttpMessageBuilder
- See Also:
-
trailers
public AbstractHttpRequestBuilder trailers(Iterable<? extends Map.Entry<? extends CharSequence, String>> trailers) Description copied from interface:HttpMessageSetters
Adds HTTP trailers for this message.- Specified by:
trailers
in interfaceHttpMessageSetters
- Specified by:
trailers
in interfaceHttpRequestSetters
- Overrides:
trailers
in classAbstractHttpMessageBuilder
-
pathParam
Description copied from interface:HttpRequestSetters
Sets a path param for this request. For example:HttpRequest.builder() .get("/{foo}") .pathParam("foo", "bar") .build(); // GET `/bar`
- Specified by:
pathParam
in interfaceHttpRequestSetters
- Specified by:
pathParam
in interfacePathAndQueryParamSetters
-
pathParams
Description copied from interface:HttpRequestSetters
Sets multiple path params for this request. For example:HttpRequest.builder() .get("/{foo}/:bar") .pathParams(Map.of("foo", 1, "bar", 2)) .build(); // GET `/1/2`
- Specified by:
pathParams
in interfaceHttpRequestSetters
- Specified by:
pathParams
in interfacePathAndQueryParamSetters
-
disablePathParams
Description copied from interface:HttpRequestSetters
Disables path parameters substitution. If path parameter is not disabled and a parameter's, specified using{}
or:
, value is not found, anIllegalStateException
is thrown.- Specified by:
disablePathParams
in interfaceHttpRequestSetters
- Specified by:
disablePathParams
in interfacePathAndQueryParamSetters
-
queryParam
Description copied from interface:HttpRequestSetters
Adds a query param for this request. For example:HttpRequest.builder() .get("/endpoint") .queryParam("foo", "bar") .build(); // GET `/endpoint?foo=bar`
- Specified by:
queryParam
in interfaceHttpRequestSetters
- Specified by:
queryParam
in interfacePathAndQueryParamSetters
-
queryParams
public AbstractHttpRequestBuilder queryParams(Iterable<? extends Map.Entry<? extends String, String>> queryParams) Description copied from interface:HttpRequestSetters
Adds multiple query params for this request. For example:HttpRequest.builder() .get("/endpoint") .queryParams(QueryParams.of("from", "foo", "limit", 10)) .build(); // GET `/endpoint?from=foo&limit=10`
- Specified by:
queryParams
in interfaceHttpRequestSetters
- Specified by:
queryParams
in interfacePathAndQueryParamSetters
- See Also:
-
cookie
Description copied from interface:HttpRequestSetters
Sets a cookie for this request. For example:HttpRequest.builder() .get("/") .cookie(Cookie.ofSecure("cookie", "foo")) .build();
- Specified by:
cookie
in interfaceHttpMessageSetters
- Specified by:
cookie
in interfaceHttpRequestSetters
- See Also:
-
cookies
Description copied from interface:HttpRequestSetters
Sets multiple cookies for this request. For example:HttpRequest.builder() .get("/") .cookies(Cookies.ofSecure(Cookie.ofSecure("cookie1", "foo"), Cookie.ofSecure("cookie2", "bar"))) .build();
- Specified by:
cookies
in interfaceHttpMessageSetters
- Specified by:
cookies
in interfaceHttpRequestSetters
- See Also:
-
buildRequest
Creates a newHttpRequest
.
-