public class Request extends Object
Modifier | Constructor and Description |
---|---|
protected |
Request() |
Modifier and Type | Method and Description |
---|---|
Object |
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()
Returns all attributes
|
String |
body()
Returns the request body sent by the client
|
int |
contentLength()
Returns the length of request.body
|
String |
contentType()
Returns the content type of the body
|
String |
cookie(String name)
Gets cookie by name.
|
Map<String,String> |
cookies() |
Set<String> |
headers()
Returns all headers
|
String |
headers(String header)
Returns the value of the provided header
|
String |
host()
Returns the host
|
String |
ip()
Returns the client's IP address
|
String |
params(String param)
Returns the value of the provided route pattern parameter.
|
String |
pathInfo()
Returns the path info
Example return: "/example/foo"
|
int |
port()
Returns the server port
|
QueryParamsMap |
queryMap() |
QueryParamsMap |
queryMap(String key) |
Set<String> |
queryParams()
Returns all query parameters
|
String |
queryParams(String queryParam)
Returns the value of the provided queryParam
Example: query parameter 'id' from the following request URI: /hello?id=foo
|
String |
queryString()
Returns the query string
|
javax.servlet.http.HttpServletRequest |
raw()
Gets the raw HttpServletRequest object handed in by Jetty
|
String |
requestMethod()
Returns request method e.g.
|
String |
scheme()
Returns the scheme
|
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()
Returns an arrat containing the splat (wildcard) parameters
|
String |
url()
Returns the URL string
|
String |
userAgent()
Returns the user-agent
|
public String params(String param)
public String[] splat()
public String requestMethod()
public String scheme()
public String host()
public String userAgent()
public int port()
public String pathInfo()
public String url()
public String contentType()
public String ip()
public String body()
public int contentLength()
public String queryParams(String queryParam)
public String queryString()
public void attribute(String attribute, Object value)
attribute
- The attributevalue
- The attribute valuepublic Object attribute(String attribute)
attribute
- The attribute value or null if not presentpublic javax.servlet.http.HttpServletRequest raw()
public QueryParamsMap queryMap()
public QueryParamsMap queryMap(String key)
public 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()
Copyright © 2013. All Rights Reserved.