Class RequestWrapper


  • final class RequestWrapper
    extends Request
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Request delegate  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private RequestWrapper()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T attribute​(java.lang.String attribute)
      Gets the value of the provided attribute
      void attribute​(java.lang.String attribute, java.lang.Object value)
      Sets an attribute on the request (can be fetched in filters/routes later in the chain)
      java.util.Set<java.lang.String> attributes()  
      java.lang.String body()  
      byte[] bodyAsBytes()  
      void changeMatch​(RouteMatch match)  
      int contentLength()  
      java.lang.String contentType()  
      java.lang.String contextPath()  
      java.lang.String cookie​(java.lang.String name)
      Gets cookie by name.
      java.util.Map<java.lang.String,​java.lang.String> cookies()  
      (package private) static RequestWrapper create()  
      boolean equals​(java.lang.Object obj)  
      (package private) Request getDelegate()  
      int hashCode()  
      java.util.Set<java.lang.String> headers()  
      java.lang.String headers​(java.lang.String header)
      Gets the value for the provided header
      java.lang.String host()  
      java.lang.String ip()  
      java.lang.String matchedPath()  
      java.util.Map<java.lang.String,​java.lang.String> params()
      Returns the map containing all route params
      java.lang.String params​(java.lang.String param)
      Returns the value of the provided route pattern parameter.
      java.lang.String pathInfo()  
      int port()  
      java.lang.String protocol()  
      QueryParamsMap queryMap()  
      QueryParamsMap queryMap​(java.lang.String key)  
      java.util.Set<java.lang.String> queryParams()  
      java.lang.String queryParams​(java.lang.String queryParam)
      Gets the query param
      java.lang.String queryParamsSafe​(java.lang.String queryParam)
      Gets the query param and encode it
      java.lang.String[] queryParamsValues​(java.lang.String queryParam)
      Gets all the values of the query param Example: query parameter 'id' from the following request URI: /hello?id=foo&id=bar
      java.lang.String queryString()  
      javax.servlet.http.HttpServletRequest raw()  
      java.lang.String requestMethod()  
      java.lang.String scheme()  
      java.lang.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.
      void setDelegate​(Request delegate)  
      java.lang.String[] splat()  
      java.lang.String toString()  
      java.lang.String uri()  
      java.lang.String url()  
      java.lang.String userAgent()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • delegate

        private Request delegate
    • Constructor Detail

      • RequestWrapper

        private RequestWrapper()
    • Method Detail

      • setDelegate

        public void setDelegate​(Request delegate)
      • getDelegate

        Request getDelegate()
      • requestMethod

        public java.lang.String requestMethod()
        Overrides:
        requestMethod in class Request
        Returns:
        request method e.g. GET, POST, PUT, ...
      • scheme

        public java.lang.String scheme()
        Overrides:
        scheme in class Request
        Returns:
        the scheme
      • port

        public int port()
        Overrides:
        port in class Request
        Returns:
        the server port
      • pathInfo

        public java.lang.String pathInfo()
        Overrides:
        pathInfo in class Request
        Returns:
        the path info Example return: "/example/foo"
      • matchedPath

        public java.lang.String matchedPath()
        Overrides:
        matchedPath in class Request
        Returns:
        the matched route Example return: "/account/:accountId"
      • servletPath

        public java.lang.String servletPath()
        Overrides:
        servletPath in class Request
        Returns:
        the servlet path
      • contextPath

        public java.lang.String contextPath()
        Overrides:
        contextPath in class Request
        Returns:
        the context path
      • contentType

        public java.lang.String contentType()
        Overrides:
        contentType in class Request
        Returns:
        the content type of the body
      • body

        public java.lang.String body()
        Overrides:
        body in class Request
        Returns:
        the request body sent by the client
      • contentLength

        public int contentLength()
        Overrides:
        contentLength in class Request
        Returns:
        the length of request.body
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • params

        public java.util.Map<java.lang.String,​java.lang.String> params()
        Description copied from class: Request
        Returns the map containing all route params
        Overrides:
        params in class Request
        Returns:
        a map containing all route params
      • params

        public java.lang.String params​(java.lang.String param)
        Description copied from class: Request
        Returns the value of the provided route pattern parameter. Example: parameter 'name' from the following pattern: (get '/hello/:name')
        Overrides:
        params in class Request
        Parameters:
        param - the param
        Returns:
        null if the given param is null or not found
      • splat

        public java.lang.String[] splat()
        Overrides:
        splat in class Request
        Returns:
        an array containing the splat (wildcard) parameters
      • host

        public java.lang.String host()
        Overrides:
        host in class Request
        Returns:
        the host
      • ip

        public java.lang.String ip()
        Overrides:
        ip in class Request
        Returns:
        the client's IP address
      • queryParams

        public java.lang.String queryParams​(java.lang.String queryParam)
        Description copied from class: Request
        Gets the query param
        Overrides:
        queryParams in class Request
        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

        public java.lang.String queryParamsSafe​(java.lang.String queryParam)
        Description copied from class: Request
        Gets the query param and encode it
        Overrides:
        queryParamsSafe in class Request
        Parameters:
        queryParam - the query parameter
        Returns:
        the encode value of the provided queryParam Example: query parameter 'me' from the URI: /hello?id=fool.
      • queryParamsValues

        public java.lang.String[] queryParamsValues​(java.lang.String queryParam)
        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 class Request
        Parameters:
        queryParam - the query parameter
        Returns:
        the values of the provided queryParam, null if it doesn't exists
      • headers

        public java.lang.String headers​(java.lang.String header)
        Description copied from class: Request
        Gets the value for the provided header
        Overrides:
        headers in class Request
        Parameters:
        header - the header
        Returns:
        the value of the provided header
      • queryParams

        public java.util.Set<java.lang.String> queryParams()
        Overrides:
        queryParams in class Request
        Returns:
        all query parameters
      • headers

        public java.util.Set<java.lang.String> headers()
        Overrides:
        headers in class Request
        Returns:
        all headers
      • queryString

        public java.lang.String queryString()
        Overrides:
        queryString in class Request
        Returns:
        the query string
      • raw

        public javax.servlet.http.HttpServletRequest raw()
        Overrides:
        raw in class Request
        Returns:
        the raw HttpServletRequest object handed in by Jetty
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • userAgent

        public java.lang.String userAgent()
        Overrides:
        userAgent in class Request
        Returns:
        the user-agent
      • url

        public java.lang.String url()
        Overrides:
        url in class Request
        Returns:
        the URL string
      • uri

        public java.lang.String uri()
        Overrides:
        uri in class Request
        Returns:
        the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
      • protocol

        public java.lang.String protocol()
        Overrides:
        protocol in class Request
        Returns:
        Returns the name and version of the protocol the request uses
      • attribute

        public void attribute​(java.lang.String attribute,
                              java.lang.Object value)
        Description copied from class: Request
        Sets an attribute on the request (can be fetched in filters/routes later in the chain)
        Overrides:
        attribute in class Request
        Parameters:
        attribute - The attribute
        value - The attribute value
      • attribute

        public <T> T attribute​(java.lang.String attribute)
        Description copied from class: Request
        Gets the value of the provided attribute
        Overrides:
        attribute in class Request
        Type Parameters:
        T - the type parameter.
        Parameters:
        attribute - The attribute value or null if not present
        Returns:
        the value for the provided attribute
      • attributes

        public java.util.Set<java.lang.String> attributes()
        Overrides:
        attributes in class Request
        Returns:
        all attributes
      • session

        public Session 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.
        Overrides:
        session in class Request
        Returns:
        the session associated with this request
      • session

        public Session session​(boolean create)
        Description copied from class: Request
        Returns the current session associated with this request, or if there is no current session and create is true, returns a new session.
        Overrides:
        session in class Request
        Parameters:
        create - true to create a new session for this request if necessary; false to return null if there's no current session
        Returns:
        the session associated with this request or null if create is false and the request has no valid session
      • queryMap

        public QueryParamsMap queryMap​(java.lang.String key)
        Overrides:
        queryMap in class Request
        Parameters:
        key - the key
        Returns:
        the query map
      • cookies

        public java.util.Map<java.lang.String,​java.lang.String> cookies()
        Overrides:
        cookies in class Request
        Returns:
        request cookies (or empty Map if cookies aren't present)
      • cookie

        public java.lang.String cookie​(java.lang.String name)
        Description copied from class: Request
        Gets cookie by name.
        Overrides:
        cookie in class Request
        Parameters:
        name - name of the cookie
        Returns:
        cookie value or null if the cookie was not found