public interface RequestAccess
Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
LOGGER |
Modifier and Type | Method and Description |
---|---|
default AppContext |
appContext()
Returns instance of
AppContext . |
default String |
context()
Provides a context of the request - usually an app name (as seen on URL of request).
|
default Cookie |
cookie(String name)
Returns a cookie by name, null if not found.
|
default List<Cookie> |
cookies()
Returns collection of all cookies browser sent.
|
default String |
cookieValue(String name)
Convenience method, returns cookie value.
|
default boolean |
exists(String name)
Tests if a request parameter exists.
|
default String |
format()
Returns a format part of the URI, or null if URI does not have a format part.
|
default String |
getId()
Returns value of ID if one is present on a URL.
|
default Locale |
getLocale()
Same as
locale() . |
default String |
getRequestHost()
This method returns a host name of a web server if this container is fronted by one, such that
it sets a header
X-Forwarded-Host on the request and forwards it to the Java container. |
default int |
getRequestPort()
This method returns a port of a web server if this Java container is fronted by one, such that
it sets a header
X-Forwarded-Port on the request and forwards it to the Java container. |
default String |
getRequestProperties() |
default String |
getRequestProtocol()
This method returns a protocol of a request to web server if this container is fronted by one, such that
it sets a header
X-Forwarded-Proto on the request and forwards it to the Java container. |
default Route |
getRoute()
Returns instance of
Route to be used for potential conditional logic inside controller filters. |
default String |
header(String name)
Returns a request header by name.
|
default Map<String,String> |
headers()
Returns all headers from a request keyed by header name.
|
default String |
host()
Returns local host name on which request was received.
|
default String |
ipAddress()
Returns local IP address on which request was received.
|
default String |
ipForwardedFor()
Returns IP address that the web server forwarded request for.
|
default boolean |
isDelete()
True if this request uses HTTP DELETE method, false otherwise.
|
default boolean |
isGet()
True if this request uses HTTP GET method, false otherwise.
|
default boolean |
isHead()
True if this request uses HTTP HEAD method, false otherwise.
|
default boolean |
isMethod(String method) |
default boolean |
isMultipartContent() |
default boolean |
isPost()
True if this request uses HTTP POST method, false otherwise.
|
default boolean |
isPut()
True if this request uses HTTP PUT method, false otherwise.
|
default boolean |
isXhr()
Returns true if this request is Ajax.
|
default Locale |
locale()
Returns locale of request.
|
default String |
method()
Returns an HTTP method from the request.
|
default String |
param(String name)
Returns value of routing user segment, or route wild card value, or request parameter.
|
default String |
param(String name,
List<FormItem> formItems)
Convenience method to get a parameter value in case
multipart/form-data request was used. |
default Map<String,String[]> |
params()
Returns an instance of
java.util.Map containing parameter names as keys and parameter values as map values. |
default List<String> |
params(String name)
Returns multiple request values for a name.
|
default List<String> |
params(String name,
List<FormItem> formItems)
Convenience method to get parameter values in case
multipart/form-data request was used. |
default Map<String,String> |
params1st()
Returns a map where keys are names of all parameters, while values are the first value for each parameter, even
if such parameter has more than one value submitted.
|
default Map<String,String> |
params1st(List<FormItem> formItems)
Convenience method to get parameters in case
multipart/form-data request was used. |
default String |
path()
Returns a path of the request.
|
default int |
port()
Returns port on which the of the server received current request.
|
default String |
protocol()
Returns protocol of request, for example: HTTP/1.1.
|
default String |
queryString()
Returns query string of the request.
|
default String |
remoteAddress()
IP address of the requesting client.
|
default String |
remoteHost()
Host name of the requesting client.
|
default boolean |
requestHas(String name)
Synonym of
exists(String) . |
default String |
servletPath() |
default Object |
session(String name) |
default void |
session(String name,
Object value)
Sets an object on a current session.
|
default String |
uri()
Returns URI, or a full path of request.
|
default String |
url()
Returns a full URL of the request, all except a query string.
|
default String |
userAgent()
Helper method, returns user-agent header of the request.
|
default boolean |
xhr()
Synonym for
isXhr() . |
default boolean isMultipartContent()
default String param(String name)
IllegalArgumentException
.name
- name of parameter.default String param(String name, List<FormItem> formItems)
multipart/form-data
request was used.
Returns a value of one named parameter from request. Will only return form fields, and not files.name
- name of parameter.formItems
- form items retrieved from multipart/form-data
request.multipart/form-data
request or null if not found.default String getId()
/controller/action/id
.
This depends on a type of a URI, and whether controller is RESTful or not.default String format()
/books.xml
, here "xml" is a format.default AppContext appContext()
AppContext
.AppContext
.default boolean isXhr()
default String userAgent()
default boolean xhr()
isXhr()
.default Route getRoute()
Route
to be used for potential conditional logic inside controller filters.Route
default boolean exists(String name)
name
- name of request parameter to test.default boolean requestHas(String name)
exists(String)
.name
- name of request parameter to test.default String host()
default String ipAddress()
default String getRequestProtocol()
X-Forwarded-Proto
on the request and forwards it to the Java container.
If such header is not present, than the protocol()
method is used.X-Forwarded-Proto
header is found, otherwise current
protocol.default int getRequestPort()
X-Forwarded-Port
on the request and forwards it to the Java container.
If such header is not present, than the port()
method is used.X-Forwarded-Port
header is found, otherwise port of the Java container.default int port()
default String protocol()
default String getRequestHost()
X-Forwarded-Host
on the request and forwards it to the Java container.
If such header is not present, than the host()
method is used.X-Forwarded-Host
header is found, otherwise local host name.default String ipForwardedFor()
default List<String> params(String name)
name
- name of multiple values from request.default List<String> params(String name, List<FormItem> formItems)
multipart/form-data
request was used.
Returns multiple request values for a name.name
- name of multiple values from request.formItems
- form items retrieved from multipart/form-data
request.default Map<String,String> params1st()
default Map<String,String> params1st(List<FormItem> formItems)
multipart/form-data
request was used.
Returns a map where keys are names of all parameters, while values are the first value for each parameter, even
if such parameter has more than one value submitted.formItems
- form items retrieved from multipart/form-data
request.default Map<String,String[]> params()
java.util.Map
containing parameter names as keys and parameter values as map values.
The keys in the parameter map are of type String. The values in the parameter map are of type String array.java.util.Map
containing parameter names as keys and parameter values as map values.
The keys in the parameter map are of type String. The values in the parameter map are of type String array.default Locale locale()
default List<Cookie> cookies()
default Cookie cookie(String name)
name
- name of a cookie.default String cookieValue(String name)
name
- name of cookie.default String path()
/controller/action/id
default String url()
default String queryString()
default String method()
default boolean isGet()
default boolean isPost()
default boolean isPut()
default boolean isDelete()
default boolean isMethod(String method)
default boolean isHead()
default String context()
/mywebapp
default String uri()
/mywebapp/controller/action/id
default String remoteHost()
default String remoteAddress()
default String header(String name)
name
- name of headerdefault Map<String,String> headers()
default Object session(String name)
name
- name of an object in sessiondefault void session(String name, Object value)
name
- name of objectvalue
- value of objectdefault String getRequestProperties()
default String servletPath()
Copyright © 2020 JavaLite. All rights reserved.