Package io.mangoo.routing.bindings
Class Request
- java.lang.Object
-
- io.mangoo.routing.bindings.Validator
-
- io.mangoo.routing.bindings.Request
-
- All Implemented Interfaces:
Serializable
public class Request extends Validator
- Author:
- svenkubiak
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(String key, Object value)Adds an attribute to the internal attributes mapbooleanauthenticityMatches()Checks if the session bound authenticity token matches the client sent authenticity tokenStringgetAcceptLanguage()Retrieves a the clients accepted languagesObjectgetAttribute(String key)Returns an object attribute from a given keyMap<String,Object>getAttributes()AuthenticationgetAuthentication()StringgetBody()Map<String,Object>getBodyAsJsonMap()com.jayway.jsonpath.ReadContextgetBodyAsJsonPath()StringgetCharset()Returns the request charset.longgetContentLength()io.undertow.server.handlers.CookiegetCookie(String name)Retrieves a single cookie from the requestMap<String,io.undertow.server.handlers.Cookie>getCookies()StringgetHeader(io.undertow.util.HttpString headerName)Retrieves a specific header value by its nameStringgetHeader(String headerName)Retrieves a specific header value by its nameio.undertow.util.HeaderMapgetHeaders()Retrieves a list of all headers send by the clientio.undertow.util.HttpStringgetMethod()Get the HTTP request method.Map<String,String>getParameter()Retrieves a map of request parameter (request or query parameter)StringgetParameter(String key)Retrieves a request parameter (request or query parameter) by its nameStringgetPath()The request path.StringgetScheme()Get the request URI scheme.SessiongetSession()StringgetURI()The original request URI.StringgetURL()Reconstructs the complete URL as seen by the user.RequestwithAuthentication(Authentication authentication)RequestwithAuthenticity(String authenticity)RequestwithBody(String body)RequestwithParameter(Map<String,String> parameter)RequestwithSession(Session session)-
Methods inherited from class io.mangoo.routing.bindings.Validator
addValue, expectDomainName, expectDomainName, expectEmail, expectEmail, expectExactMatch, expectExactMatch, expectIpv4, expectIpv4, expectIpv6, expectIpv6, expectMatch, expectMatch, expectMatch, expectMatch, expectMax, expectMax, expectMin, expectMin, expectNumeric, expectNumeric, expectRange, expectRange, expectRegex, expectRegex, expectUrl, expectUrl, expectValue, expectValue, get, getError, getErrors, hasError, hasErrors, invalidate, isValid, setValues, validateFalse, validateFalse, validateNotNull, validateNotNull, validateNull, validateNull, validateTrue, validateTrue
-
-
-
-
Method Detail
-
withAuthentication
public Request withAuthentication(Authentication authentication)
-
getSession
public Session getSession()
- Returns:
- The current session
-
getBody
public String getBody()
- Returns:
- The request body
-
getBodyAsJsonMap
public Map<String,Object> getBodyAsJsonMap()
- Returns:
- The request body as Map object
-
getBodyAsJsonPath
public com.jayway.jsonpath.ReadContext getBodyAsJsonPath()
- Returns:
- The request body as JsonPath object
-
authenticityMatches
public boolean authenticityMatches()
Checks if the session bound authenticity token matches the client sent authenticity token- Returns:
- True if the token matches, false otherwise
-
getAuthentication
public Authentication getAuthentication()
- Returns:
- The current authentication
-
getParameter
public String getParameter(String key)
Retrieves a request parameter (request or query parameter) by its name- Parameters:
key- The key to lookup the parameter- Returns:
- The value for the given or null if none found
-
getParameter
public Map<String,String> getParameter()
Retrieves a map of request parameter (request or query parameter)- Returns:
- Map of request and query parameter
-
getHeaders
public io.undertow.util.HeaderMap getHeaders()
Retrieves a list of all headers send by the client- Returns:
- A HeaderMap of client sent headers
-
getAcceptLanguage
public String getAcceptLanguage()
Retrieves a the clients accepted languages- Returns:
- the string value of the clients accepted languages
-
getHeader
public String getHeader(io.undertow.util.HttpString headerName)
Retrieves a specific header value by its name- Parameters:
headerName- The name of the header to retrieve- Returns:
- The value of the header or null if none found
-
getHeader
public String getHeader(String headerName)
Retrieves a specific header value by its name- Parameters:
headerName- The name of the header to retrieve- Returns:
- The value of the header or null if none found
-
getURI
public String getURI()
The original request URI. This will include the host name, protocol etc if it was specified by the client. This is not decoded in any way, and does not include the query string. Examples: GET http://localhost:8080/myFile.jsf?foo=bar HTTP/1.1 -> 'http://localhost:8080/myFile.jsf' POST /my+File.jsf?foo=bar HTTP/1.1 -> '/my+File.jsf'- Returns:
- The request URI
-
getURL
public String getURL()
Reconstructs the complete URL as seen by the user. This includes scheme, host name etc, but does not include query string. This is not decoded.- Returns:
- The request URL
-
getCookies
public Map<String,io.undertow.server.handlers.Cookie> getCookies()
- Returns:
- An immutable map of request cookies
-
getCookie
public io.undertow.server.handlers.Cookie getCookie(String name)
Retrieves a single cookie from the request- Parameters:
name- The name of the cookie- Returns:
- The Cookie
-
getScheme
public String getScheme()
Get the request URI scheme. Normally this is one ofhttporhttps.- Returns:
- the request URI scheme
-
getCharset
public String getCharset()
Returns the request charset. If none was explicitly specified it will return "ISO-8859-1", which is the default charset for HTTP requests.- Returns:
- The character encoding
-
addAttribute
public void addAttribute(String key, Object value)
Adds an attribute to the internal attributes map- Parameters:
key- The key to store the attributevalue- The value to store
-
getContentLength
public long getContentLength()
- Returns:
- The content length of the request, or
-1if it has not been set
-
getMethod
public io.undertow.util.HttpString getMethod()
Get the HTTP request method. Normally this is one of the strings listed inMethods.- Returns:
- the HTTP request method
-
getPath
public String getPath()
The request path. This will be decoded by the server, and does not include the query string. This path is not canonicalized, so care must be taken to ensure that escape attacks are not possible. Examples: GET http://localhost:8080/b/../my+File.jsf?foo=bar HTTP/1.1 -> '/b/../my+File.jsf' POST /my+File.jsf?foo=bar HTTP/1.1 -> '/my File.jsf'- Returns:
- The request path
-
getAttribute
public Object getAttribute(String key)
Returns an object attribute from a given key- Parameters:
key- The key the attribute is stored- Returns:
- Object the value from the attribues map
-
-