Package com.linecorp.armeria.common
Class AbstractHttpRequestBuilder
java.lang.Object
com.linecorp.armeria.common.AbstractHttpRequestBuilder
- Direct Known Subclasses:
HttpRequestBuilder
,WebClientRequestPreparation
Builds a new
HttpRequest
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected HttpRequest
Creates a newHttpRequest
.Sets the content for this request.Sets the content for this request.content(MediaType contentType, CharSequence content)
Sets the content for this request.Sets the content for this request.Sets the content for this request.Sets thePublisher
for this request.Sets a cookie for this request.Sets multiple cookies for this request.Shortcut to set DELETE method and path.Disables path parameters substitution.Shortcut to set GET method and path.Shortcut to set HEAD method and path.header(CharSequence name, Object value)
Adds a header for this request.headers(Iterable<? extends Map.Entry<? extends CharSequence,String>> headers)
Adds multiple headers for this request.method(HttpMethod method)
Sets the method for this request.Shortcut to set OPTIONS method and path.Shortcut to set 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.Shortcut to set POST method and path.Shortcut to set PUT method and path.queryParam(String name, Object value)
Sets a query param for this request.queryParams(Iterable<? extends Map.Entry<? extends String,String>> queryParams)
Sets multiple query params for this request.Shortcut to set TRACE method and path.trailers(Iterable<? extends Map.Entry<? extends CharSequence,String>> trailers)
Sets HTTP trailers for this request.
-
Constructor Details
-
AbstractHttpRequestBuilder
public AbstractHttpRequestBuilder()
-
-
Method Details
-
get
Shortcut to set GET method and path. -
post
Shortcut to set POST method and path. -
put
Shortcut to set PUT method and path. -
delete
Shortcut to set DELETE method and path. -
patch
Shortcut to set PATCH method and path. -
options
Shortcut to set OPTIONS method and path. -
head
Shortcut to set HEAD method and path. -
trace
Shortcut to set TRACE method and path. -
method
Sets the method for this request.- See Also:
HttpMethod
-
path
Sets the path for this request. -
content
Sets the content for this request. -
content
Sets the content for this request. -
content
@FormatMethod public AbstractHttpRequestBuilder content(MediaType contentType, @FormatString String format, Object... content)Sets the content for this request. Thecontent
is formatted byString.format(Locale, String, Object...)
with English locale. -
content
Sets the content for this request. Thecontent
will be wrapped usingHttpData.wrap(byte[])
, so any changes made tocontent
will be reflected in the request. -
content
Sets the content for this request. -
content
public AbstractHttpRequestBuilder content(MediaType contentType, org.reactivestreams.Publisher<? extends HttpData> publisher)Sets thePublisher
for this request. -
header
Adds a header for this request. For example:HttpRequest.builder() .get("/") .header("authorization", "foo") .build();
-
headers
public AbstractHttpRequestBuilder headers(Iterable<? extends Map.Entry<? extends CharSequence,String>> headers)Adds multiple headers for this request. For example:HttpRequest.builder() .get("/") .headers(HttpHeaders.of("authorization", "foo", "bar", "baz")) .build();
- See Also:
HttpHeaders
-
trailers
public AbstractHttpRequestBuilder trailers(Iterable<? extends Map.Entry<? extends CharSequence,String>> trailers)Sets HTTP trailers for this request. -
pathParam
Sets a path param for this request. For example:HttpRequest.builder() .get("/{foo}") .pathParam("foo", "bar") .build(); // GET `/bar`
-
pathParams
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`
-
disablePathParams
Disables path parameters substitution. If path parameter is not disabled and a parameter's, specified using{}
or:
, value is not found, anIllegalStateException
is thrown. -
queryParam
Sets a query param for this request. For example:HttpRequest.builder() .get("/endpoint") .queryParam("foo", "bar") .build(); // GET `/endpoint?foo=bar`
-
queryParams
public AbstractHttpRequestBuilder queryParams(Iterable<? extends Map.Entry<? extends String,String>> queryParams)Sets 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`
- See Also:
QueryParams
-
cookie
Sets a cookie for this request. For example:HttpRequest.builder() .get("/") .cookie(Cookie.of("cookie", "foo")) .build();
- See Also:
Cookie
-
cookies
Sets multiple cookies for this request. For example:HttpRequest.builder() .get("/") .cookies(Cookies.of(Cookie.of("cookie1", "foo"), Cookie.of("cookie2", "bar"))) .build();
- See Also:
Cookies
-
buildRequest
Creates a newHttpRequest
.
-