Package spark.http.matching
Class RequestWrapper
java.lang.Object
spark.Request
spark.http.matching.RequestWrapper
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> T
Gets the value of the provided attributevoid
Sets an attribute on the request (can be fetched in filters/routes later in the chain)body()
byte[]
void
changeMatch
(RouteMatch match) int
Gets cookie by name.cookies()
(package private) static RequestWrapper
create()
boolean
(package private) Request
int
hashCode()
headers()
Gets the value for the provided headerhost()
ip()
params()
Returns the map containing all route paramsReturns the value of the provided route pattern parameter.pathInfo()
int
port()
protocol()
queryMap()
queryParams
(String queryParam) Gets the query paramqueryParamsSafe
(String queryParam) Gets the query param and encode itString[]
queryParamsValues
(String queryParam) Gets all the values of the query param Example: query parameter 'id' from the following request URI: /hello?id=foo&id=barjavax.servlet.http.HttpServletRequest
raw()
scheme()
session()
Returns the current session associated with this request, or if the request does not have a session, creates one.session
(boolean create) Returns the current session associated with this request, or if there is no current session andcreate
is true, returns a new session.void
setDelegate
(Request delegate) String[]
splat()
toString()
uri()
url()
Methods inherited from class spark.Request
queryParamOrDefault
-
Field Details
-
delegate
-
-
Constructor Details
-
RequestWrapper
private RequestWrapper()
-
-
Method Details
-
create
-
setDelegate
-
getDelegate
Request getDelegate() -
changeMatch
- Overrides:
changeMatch
in classRequest
-
requestMethod
- Overrides:
requestMethod
in classRequest
- Returns:
- request method e.g. GET, POST, PUT, ...
-
scheme
-
port
public int port() -
pathInfo
-
matchedPath
- Overrides:
matchedPath
in classRequest
- Returns:
- the matched route Example return: "/account/:accountId"
-
servletPath
- Overrides:
servletPath
in classRequest
- Returns:
- the servlet path
-
contextPath
- Overrides:
contextPath
in classRequest
- Returns:
- the context path
-
contentType
- Overrides:
contentType
in classRequest
- Returns:
- the content type of the body
-
body
-
bodyAsBytes
public byte[] bodyAsBytes()- Overrides:
bodyAsBytes
in classRequest
-
contentLength
public int contentLength()- Overrides:
contentLength
in classRequest
- Returns:
- the length of request.body
-
equals
-
hashCode
public int hashCode() -
params
Description copied from class:Request
Returns the map containing all route params -
params
Description copied from class:Request
Returns the value of the provided route pattern parameter. Example: parameter 'name' from the following pattern: (get '/hello/:name') -
splat
-
host
-
ip
-
queryParams
Description copied from class:Request
Gets the query param- Overrides:
queryParams
in classRequest
- Parameters:
queryParam
- the query parameter- Returns:
- the value of the provided queryParam Example: query parameter 'id' from the following request URI: /hello?id=foo
-
queryParamsSafe
Description copied from class:Request
Gets the query param and encode it- Overrides:
queryParamsSafe
in classRequest
- Parameters:
queryParam
- the query parameter- Returns:
- the encode value of the provided queryParam Example: query parameter 'me' from the URI: /hello?id=fool.
-
queryParamsValues
Description copied from class:Request
Gets all the values of the query param Example: query parameter 'id' from the following request URI: /hello?id=foo&id=bar- Overrides:
queryParamsValues
in classRequest
- Parameters:
queryParam
- the query parameter- Returns:
- the values of the provided queryParam, null if it doesn't exists
-
headers
Description copied from class:Request
Gets the value for the provided header -
queryParams
- Overrides:
queryParams
in classRequest
- Returns:
- all query parameters
-
headers
-
queryString
- Overrides:
queryString
in classRequest
- Returns:
- the query string
-
raw
public javax.servlet.http.HttpServletRequest raw() -
toString
-
userAgent
-
url
-
uri
-
protocol
-
attribute
Description copied from class:Request
Sets an attribute on the request (can be fetched in filters/routes later in the chain) -
attribute
Description copied from class:Request
Gets the value of the provided attribute -
attributes
- Overrides:
attributes
in classRequest
- Returns:
- all attributes
-
session
Description copied from class:Request
Returns the current session associated with this request, or if the request does not have a session, creates one. -
session
Description copied from class:Request
Returns the current session associated with this request, or if there is no current session andcreate
is true, returns a new session. -
queryMap
-
queryMap
-
cookies
-
cookie
Description copied from class:Request
Gets cookie by name.
-