public class Request extends Object
Modifier | Constructor and Description |
---|---|
protected |
Request() |
Modifier and Type | Method and Description |
---|---|
<T> T |
attribute(String attribute)
Gets the value of the provided attribute
|
void |
attribute(String attribute,
Object value)
Sets an attribute on the request (can be fetched in filters/routes later in the chain)
|
Set<String> |
attributes() |
String |
body() |
byte[] |
bodyAsBytes() |
protected void |
changeMatch(RouteMatch match) |
int |
contentLength() |
String |
contentType() |
String |
contextPath() |
String |
cookie(String name)
Gets cookie by name.
|
Map<String,String> |
cookies() |
Set<String> |
headers() |
String |
headers(String header)
Gets the value for the provided header
|
String |
host() |
String |
ip() |
Map<String,String> |
params()
Returns the map containing all route params
|
String |
params(String param)
Returns the value of the provided route pattern parameter.
|
String |
pathInfo() |
int |
port() |
String |
protocol() |
QueryParamsMap |
queryMap() |
QueryParamsMap |
queryMap(String key) |
String |
queryParamOrDefault(String queryParam,
String defaultValue)
Gets the query param, or returns default value
|
Set<String> |
queryParams() |
String |
queryParams(String queryParam)
Gets the query param
|
String[] |
queryParamsValues(String queryParam)
Gets all the values of the query param
Example: query parameter 'id' from the following request URI: /hello?id=foo&id=bar
|
String |
queryString() |
javax.servlet.http.HttpServletRequest |
raw() |
String |
requestMethod() |
String |
scheme() |
String |
servletPath() |
Session |
session()
Returns the current session associated with this request,
or if the request does not have a session, creates one.
|
Session |
session(boolean create)
Returns the current session associated with this request, or if there is
no current session and
create is true, returns a new session. |
String[] |
splat() |
String |
uri() |
String |
url() |
String |
userAgent() |
protected void changeMatch(RouteMatch match)
public Map<String,String> params()
public String params(String param)
param
- the parampublic String[] splat()
public String requestMethod()
public String scheme()
public String host()
public String userAgent()
public int port()
public String pathInfo()
public String servletPath()
public String contextPath()
public String url()
public String contentType()
public String ip()
public String body()
public byte[] bodyAsBytes()
public int contentLength()
public String queryParams(String queryParam)
queryParam
- the query parameterpublic String queryParamOrDefault(String queryParam, String defaultValue)
queryParam
- the query parameterdefaultValue
- the default valuepublic String[] queryParamsValues(String queryParam)
queryParam
- the query parameterpublic String headers(String header)
header
- the headerpublic String queryString()
public void attribute(String attribute, Object value)
attribute
- The attributevalue
- The attribute valuepublic <T> T attribute(String attribute)
T
- the type parameter.attribute
- The attribute value or null if not presentpublic javax.servlet.http.HttpServletRequest raw()
public QueryParamsMap queryMap()
public QueryParamsMap queryMap(String key)
key
- the keypublic Session session()
public Session session(boolean create)
create
is true, returns a new session.create
- true
to create a new session for this request if necessary;
false
to return null if there's no current sessionnull
if
create
is false
and the request has no valid sessionpublic Map<String,String> cookies()
public String cookie(String name)
name
- name of the cookiepublic String uri()
public String protocol()
Copyright © 2017. All rights reserved.