public interface IRequestRequestContextAddon<R extends IRequestContext<?>>
request.| Modifier and Type | Method and Description |
|---|---|
byte[] |
getBodyAsByteArray()
The bytes of the request's body.
|
InputStream |
getBodyAsInputStream()
The raw InputStream of the request's body.
|
String |
getBodyAsString()
The request's body as a String, using the
UTF-8 encoding. |
String |
getBodyAsString(String encoding)
The request's body as a String, using the specified encoding.
|
String |
getContentType()
The Content-Type of the request, if any.
|
ContentTypeDefaults |
getContentTypeBestMatch()
Finds the best
Content-Type to use for a response
using the "Accept" header of the request. |
List<String> |
getFormData(String name)
A specific parameter submitted from a
FORM via a POST method. |
String |
getFormDataFirst(String name)
The first (and often only) value of a specific parameter submitted from a
FORM via a POST method. |
Map<String,List<String>> |
getFormDatas()
The parameters submitted from a
FORM via a POST method. |
String |
getFullUrl()
Returns the full URL, including the queryString.
|
List<String> |
getHeader(String name)
Returns the values of the specified header from the current request or
an empty list if not found.
|
String |
getHeaderFirst(String name)
The first value of the specified header from the current request.
|
Map<String,List<String>> |
getHeaders()
Returns all headers of the current request.
|
HttpMethod |
getHttpMethod()
Gets the request's
HTTP method. |
<T> T |
getJsonBody(Class<T> clazz)
The request's body deserialized to the specified
class. |
IJsonObject |
getJsonBodyAsJsonObject()
The request's body deserialized to a
IJsonObject. |
Map<String,Object> |
getJsonBodyAsMap()
The request's body deserialized to a
Map<String, Object>. |
Locale |
getLocaleBestMatch()
Find the best
Locale to use for a response
using the "Accept-Language" header of
the request. |
String |
getOriginalFullUrl()
If the request has been forwarded,
getFullUrl() is
going to return the new, forwarded, url. |
String |
getPathParam(String name)
A specific value parsed from a dynamic parameter of the route path.
|
Map<String,String> |
getPathParams()
The values parsed from the dynamic parameters of the route path.
|
String |
getQueryString()
The queryString of the request, without the "?".
|
List<String> |
getQueryStringParam(String name)
A specific parameter taken from the queryString of the request.
|
String |
getQueryStringParamFirst(String name)
The first (and often only) value of a specific parameter taken from the
queryString of the request.
|
Map<String,List<String>> |
getQueryStringParams()
The parameters taken from the queryString of the request.
|
String |
getRequestPath()
The path of the request (no querystring).
|
File |
getUploadedFileFirst(String name)
The first (and often only) uploaded file of the specified name.
|
Map<String,List<File>> |
getUploadedFiles()
The uploaded files, with their names as the keys.
|
List<File> |
getUploadedFiles(String name)
The uploaded files of the specified name.
|
<T> T |
getXmlBody(Class<T> clazz)
The request's body deserialized to the specified
class. |
IJsonObject |
getXmlBodyAsJsonObject()
The request's body deserialized to a
IJsonObject. |
Map<String,Object> |
getXmlBodyAsMap()
The request's body deserialized to a
Map<String, Object>. |
boolean |
isHTMLShouldBeReturn()
Will return
true if the request specifies
that HTML is the most appropriate format
to return. |
boolean |
isJsonShouldBeReturn()
Will return
true if the request specifies
that Json is the most appropriate format
to return. |
boolean |
isPlainTextShouldBeReturn()
Will return
true if the request specifies
that plain-text is the most appropriate format
to return. |
boolean |
isXMLShouldBeReturn()
Will return
true if the request specifies
that XML is the most appropriate format
to return. |
HttpMethod getHttpMethod()
HTTP method.ContentTypeDefaults getContentTypeBestMatch()
Content-Type to use for a response
using the "Accept" header of the request. It will
fallback to ContentTypeDefaults.TEXT if nothing more specific
is found.boolean isJsonShouldBeReturn()
true if the request specifies
that Json is the most appropriate format
to return.boolean isHTMLShouldBeReturn()
true if the request specifies
that HTML is the most appropriate format
to return.boolean isXMLShouldBeReturn()
true if the request specifies
that XML is the most appropriate format
to return.boolean isPlainTextShouldBeReturn()
true if the request specifies
that plain-text is the most appropriate format
to return.Locale getLocaleBestMatch()
Locale to use for a response
using the "Accept-Language" header of
the request.
Returns the default Locale (taken from the configurations)
if nothing more specific is found.Map<String,List<String>> getHeaders()
TreeMap which iscase insensitive for the keys.
The map is immutable.List<String> getHeader(String name)
name is case insensitive.
The list is immutable.String getHeaderFirst(String name)
name is case insensitive.
Returns null if the header is not found.String getContentType()
Content-Type of the request or null
if none was specified.String getFullUrl()
String getOriginalFullUrl()
getFullUrl() is
going to return the new, forwarded, url.
This method will always return the original url.String getRequestPath()
Map<String,String> getPathParams()
String getPathParam(String name)
name is case sensitive, since you have easy control over it.String getQueryString()
Map<String,List<String>> getQueryStringParams()
List<String> getQueryStringParam(String name)
String getQueryStringParamFirst(String name)
null if the parameter doesn't exist.InputStream getBodyAsInputStream()
byte[] getBodyAsByteArray()
String getBodyAsString()
UTF-8 encoding.
Note that the characters read cannot be read again!String getBodyAsString(String encoding)
IJsonObject getJsonBodyAsJsonObject()
IJsonObject. A valid Json body
is expected.
Note that this can only be called once.Map<String,Object> getJsonBodyAsMap()
Map<String, Object>. A valid Json body
is expected.
Note that this can only be called once.<T> T getJsonBody(Class<T> clazz)
class. A valid Json body
is expected.
Note that this can only be called once.IJsonObject getXmlBodyAsJsonObject()
IJsonObject. A valid XML body
is expected.
Note that this can only be called once.Map<String,Object> getXmlBodyAsMap()
Map<String, Object>. A valid XML body
is expected.
Note that this can only be called once.<T> T getXmlBody(Class<T> clazz)
class. A valid XML body
is expected.
Note that this can only be called once.Map<String,List<String>> getFormDatas()
FORM via a POST method.
More than one value with the same key is possible.
The names are case sensitive.
The map is immutable.List<String> getFormData(String name)
FORM via a POST method.
More than one value with the same name is possible.
The name is case sensitive.
The list is immutable.String getFormDataFirst(String name)
FORM via a POST method.
The name is case sensitive.
Returns null if the parameter doesn't exist.Map<String,List<File>> getUploadedFiles()
List<File> getUploadedFiles(String name)
name is possible.
The list is immutable.
Returns an empty list if no uploaded files of this name exists.Copyright © 2016. All rights reserved.