Class ApiRestRequest<T extends ApiRequest<T>>
- java.lang.Object
-
- io.helidon.integrations.common.rest.ApiRestRequest<T>
-
- Type Parameters:
T
- type of the request
- All Implemented Interfaces:
ApiRequest<T>
- Direct Known Subclasses:
RestRequest
public abstract class ApiRestRequest<T extends ApiRequest<T>> extends Object implements ApiRequest<T>
Common base class for REST requests. This class acts as a mutable builder without a build method, as the intended use is to pass it to aio.helidon.integrations.common.rest.RestApi
, not to send it around for parallel processing. Path is not a part of this request.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ApiRestRequest()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
addHeader(String name, String... value)
Add an HTTP header.T
addQueryParam(String name, String... value)
Add an HTTP query parameter.Map<String,List<String>>
headers()
Returns immutable configured headers.protected T
me()
Can be returned by subclasses that can be subclassed again.Map<String,List<String>>
queryParams()
Returns immutable configured query parameters.Optional<String>
requestId()
Configured request ID.T
requestId(String requestId)
Configure request ID for logging (and possibly to send over the network).Optional<MediaType>
requestMediaType()
Request media type.T
requestMediaType(MediaType mediaType)
The media type header, defaults toMediaType.APPLICATION_JSON
when JSON entity is present, toMediaType.APPLICATION_OCTET_STREAM
for publisher base requests, empty otherwise.Optional<MediaType>
responseMediaType()
Response media type.T
responseMediaType(MediaType mediaType)
The accept header, defaults toMediaType.APPLICATION_JSON
for most requests, except for requests that return publisher, which default toMediaType.APPLICATION_OCTET_STREAM
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.helidon.integrations.common.rest.ApiRequest
toJson
-
-
-
-
Method Detail
-
addHeader
public T addHeader(String name, String... value)
Add an HTTP header.- Specified by:
addHeader
in interfaceApiRequest<T extends ApiRequest<T>>
- Parameters:
name
- name of the headervalue
- header value(s)- Returns:
- updated request
-
addQueryParam
public T addQueryParam(String name, String... value)
Add an HTTP query parameter.- Specified by:
addQueryParam
in interfaceApiRequest<T extends ApiRequest<T>>
- Parameters:
name
- name of the parametervalue
- parameter value(s)- Returns:
- updated request
-
requestMediaType
public T requestMediaType(MediaType mediaType)
Description copied from interface:ApiRequest
The media type header, defaults toMediaType.APPLICATION_JSON
when JSON entity is present, toMediaType.APPLICATION_OCTET_STREAM
for publisher base requests, empty otherwise.- Specified by:
requestMediaType
in interfaceApiRequest<T extends ApiRequest<T>>
- Parameters:
mediaType
- media type of request- Returns:
- updated request
-
responseMediaType
public T responseMediaType(MediaType mediaType)
Description copied from interface:ApiRequest
The accept header, defaults toMediaType.APPLICATION_JSON
for most requests, except for requests that return publisher, which default toMediaType.APPLICATION_OCTET_STREAM
.- Specified by:
responseMediaType
in interfaceApiRequest<T extends ApiRequest<T>>
- Parameters:
mediaType
- accepted media type- Returns:
- updated request
-
requestId
public T requestId(String requestId)
Description copied from interface:ApiRequest
Configure request ID for logging (and possibly to send over the network).- Specified by:
requestId
in interfaceApiRequest<T extends ApiRequest<T>>
- Parameters:
requestId
- request id- Returns:
- updated request
-
headers
public Map<String,List<String>> headers()
Description copied from interface:ApiRequest
Returns immutable configured headers.- Specified by:
headers
in interfaceApiRequest<T extends ApiRequest<T>>
- Returns:
- headers configured for this request
-
queryParams
public Map<String,List<String>> queryParams()
Description copied from interface:ApiRequest
Returns immutable configured query parameters.- Specified by:
queryParams
in interfaceApiRequest<T extends ApiRequest<T>>
- Returns:
- query parameters configured for this request
-
requestMediaType
public Optional<MediaType> requestMediaType()
Description copied from interface:ApiRequest
Request media type.- Specified by:
requestMediaType
in interfaceApiRequest<T extends ApiRequest<T>>
- Returns:
- media type if configured
- See Also:
ApiRequest.requestMediaType(io.helidon.common.http.MediaType)
-
responseMediaType
public Optional<MediaType> responseMediaType()
Description copied from interface:ApiRequest
Response media type.- Specified by:
responseMediaType
in interfaceApiRequest<T extends ApiRequest<T>>
- Returns:
- media type if configured
- See Also:
ApiRequest.responseMediaType(io.helidon.common.http.MediaType)
-
requestId
public Optional<String> requestId()
Description copied from interface:ApiRequest
Configured request ID.- Specified by:
requestId
in interfaceApiRequest<T extends ApiRequest<T>>
- Returns:
- request ID if configured
-
me
protected T me()
Can be returned by subclasses that can be subclassed again.- Returns:
- this instance as a subclass type
-
-