|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfeign.RequestTemplate
public final class RequestTemplate
Builds a request to an http target. Not thread safe.
relationship to JAXRS 2.0
A combination of javax.ws.rs.client.WebTarget
and
javax.ws.rs.client.Invocation.Builder
, ensuring you can modify any
part of the request. However, this object is mutable, so needs to be guarded
with the copy constructor.
Constructor Summary | |
---|---|
RequestTemplate()
|
|
RequestTemplate(RequestTemplate toCopy)
|
Method Summary | |
---|---|
RequestTemplate |
append(java.lang.CharSequence value)
|
java.lang.String |
body()
|
RequestTemplate |
body(java.lang.String body)
replaces the Util.CONTENT_LENGTH header. |
java.lang.String |
bodyTemplate()
|
RequestTemplate |
bodyTemplate(java.lang.String bodyTemplate)
populated by Body |
static java.lang.String |
expand(java.lang.String template,
java.util.Map<java.lang.String,?> variables)
Expands a template , such as username , using the variables supplied. |
RequestTemplate |
header(java.lang.String configKey,
java.lang.Iterable<java.lang.String> values)
|
RequestTemplate |
header(java.lang.String configKey,
java.lang.String... values)
Replaces headers with the specified configKey with the
values supplied. |
java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> |
headers()
Returns an immutable copy of the current headers. |
RequestTemplate |
headers(java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> headers)
Replaces all existing headers with the newly supplied headers. |
RequestTemplate |
insert(int pos,
java.lang.CharSequence value)
|
java.lang.String |
method()
|
RequestTemplate |
method(java.lang.String method)
|
java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> |
queries()
Returns an immutable copy of the url decoded queries. |
RequestTemplate |
queries(java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> queries)
Replaces all existing queries with the newly supplied url decoded queries. |
RequestTemplate |
query(java.lang.String configKey,
java.lang.Iterable<java.lang.String> values)
|
RequestTemplate |
query(java.lang.String configKey,
java.lang.String... values)
Replaces queries with the specified configKey with url decoded
values supplied. |
java.lang.String |
queryLine()
|
void |
replaceQueryValues(java.util.Map<java.lang.String,?> unencoded)
Replaces query values which are templated with corresponding values from the unencoded map. |
Request |
request()
|
RequestTemplate |
resolve(java.util.Map<java.lang.String,?> unencoded)
Resolves any templated variables in the requests path, query, or headers against the supplied unencoded arguments. |
java.lang.String |
toString()
|
java.lang.String |
url()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public RequestTemplate()
public RequestTemplate(RequestTemplate toCopy)
Method Detail |
---|
public RequestTemplate resolve(java.util.Map<java.lang.String,?> unencoded)
javax.ws.rs.client.WebTarget.resolveTemplates(templateValues, true)
, except that the template values apply to any part of the request, not
just the URL
public Request request()
public static java.lang.String expand(java.lang.String template, java.util.Map<java.lang.String,?> variables)
template
, such as username
, using the variables
supplied. Any unresolved
parameters will remain.
template
,
urlencode them first.
template
- URI template that can be in level 1 RFC6570 form.variables
- to the URI template
public RequestTemplate method(java.lang.String method)
public java.lang.String method()
public RequestTemplate append(java.lang.CharSequence value)
public RequestTemplate insert(int pos, java.lang.CharSequence value)
public java.lang.String url()
public RequestTemplate query(java.lang.String configKey, java.lang.String... values)
configKey
with url decoded
values
supplied.
value
is null
, all queries with the configKey
are removed.
WebTarget.query
, except the values can be templatized.
template.query("Signature", "{signature}");
configKey
- the configKey of the queryvalues
- can be a single null to imply removing all values. Else no
values are expected to be null.queries()
public RequestTemplate query(java.lang.String configKey, java.lang.Iterable<java.lang.String> values)
public RequestTemplate queries(java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> queries)
WebTarget.queries
, except the values can be templatized.
template.queries(ImmutableMultimap.of("Signature", "{signature}"));
queries
- if null, remove all queries. else value to replace all queries
with.queries()
public java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> queries()
Request.url()
public RequestTemplate header(java.lang.String configKey, java.lang.String... values)
configKey
with the
values
supplied.
value
is null
, all headers with the configKey
are removed.
WebTarget.queries
and javax.ws.rs.client.Invocation.Builder.header
,
except the values can be templatized.
template.query("X-Application-Version", "{version}");
configKey
- the configKey of the headervalues
- can be a single null to imply removing all values. Else no
values are expected to be null.headers()
public RequestTemplate header(java.lang.String configKey, java.lang.Iterable<java.lang.String> values)
public RequestTemplate headers(java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> headers)
Invocation.Builder.headers(MultivaluedMap)
, except the
values can be templatized.
template.headers(ImmutableMultimap.of("X-Application-Version", "{version}"));
headers
- if null, remove all headers. else value to replace all headers
with.headers()
public java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> headers()
Request.headers()
public RequestTemplate body(java.lang.String body)
Util.CONTENT_LENGTH
header.
Encoder
.
Request.body()
public java.lang.String body()
public RequestTemplate bodyTemplate(java.lang.String bodyTemplate)
Body
Request.body()
public java.lang.String bodyTemplate()
Request.body()
,
expand(String, Map)
public java.lang.String toString()
toString
in class java.lang.Object
public void replaceQueryValues(java.util.Map<java.lang.String,?> unencoded)
unencoded
map.
Any unresolved queries are removed.
public java.lang.String queryLine()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |