java.lang.Object
java.net.http.HttpRequest
com.github.mizosoft.methanol.TaggableRequest
- Direct Known Subclasses:
MutableRequest
An
HttpRequest
that can carry arbitrary values, referred to as tags. Tags can be used to
carry application-specific data throughout interceptors
and listeners. Tags
are mapped by their type. One type cannot map to more than one tag.
A TaggableRequest
also carries the BodyAdapter.Hints
to be used when encoding the request
body and/or decoding the response body. Hints are like tags but are meant to carry arbitrary
values to adapters
rather than interceptors or listeners.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
AnHttpRequest.Builder
that allows attaching tags.Nested classes/interfaces inherited from class java.net.http.HttpRequest
HttpRequest.BodyPublisher, HttpRequest.BodyPublishers
-
Method Summary
Modifier and TypeMethodDescriptionstatic TaggableRequest
from
(HttpRequest request) Returns either the given request if it's aTaggableRequest
or a newTaggableRequest
copy with no tags otherwise.abstract BodyAdapter.Hints
hints()
Returns this request'sBodyAdapter.Hints
.<T> Optional
<T> Returns the tag associated with the given type if present.<T> Optional
<T> Returns the tag associated with the given type if present.static <T> Optional
<T> tagOf
(HttpRequest request, TypeRef<T> typeRef) Returns the tag associated with the given type if the given request is aTaggableRequest
and it has a tag with the given type, otherwise returns an emptyOptional
.static <T> Optional
<T> tagOf
(HttpRequest request, Class<T> type) Returns the tag associated with the given type if the given request is aTaggableRequest
and it has a tag with the given type, otherwise returns an emptyOptional
.Methods inherited from class java.net.http.HttpRequest
bodyPublisher, equals, expectContinue, hashCode, headers, method, newBuilder, newBuilder, newBuilder, timeout, uri, version
-
Method Details
-
tag
Returns the tag associated with the given type if present. -
tag
Returns the tag associated with the given type if present. -
hints
Returns this request'sBodyAdapter.Hints
. -
from
Returns either the given request if it's aTaggableRequest
or a newTaggableRequest
copy with no tags otherwise. -
tagOf
Returns the tag associated with the given type if the given request is aTaggableRequest
and it has a tag with the given type, otherwise returns an emptyOptional
. -
tagOf
Returns the tag associated with the given type if the given request is aTaggableRequest
and it has a tag with the given type, otherwise returns an emptyOptional
.
-