Class RequestWrapper

java.lang.Object
spark.Request
spark.http.matching.RequestWrapper

final class RequestWrapper extends Request
  • Field Details

    • delegate

      private Request delegate
  • Constructor Details

    • RequestWrapper

      private RequestWrapper()
  • Method Details

    • create

      static RequestWrapper create()
    • setDelegate

      public void setDelegate(Request delegate)
    • getDelegate

      Request getDelegate()
    • changeMatch

      public void changeMatch(RouteMatch match)
      Overrides:
      changeMatch in class Request
    • requestMethod

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

      public 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 String pathInfo()
      Overrides:
      pathInfo in class Request
      Returns:
      the path info Example return: "/example/foo"
    • matchedPath

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

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

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

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

      public String body()
      Overrides:
      body in class Request
      Returns:
      the request body sent by the client
    • bodyAsBytes

      public byte[] bodyAsBytes()
      Overrides:
      bodyAsBytes in class Request
    • contentLength

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

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

      public Map<String,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 String params(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 String[] splat()
      Overrides:
      splat in class Request
      Returns:
      an array containing the splat (wildcard) parameters
    • host

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

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

      public String queryParams(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 String queryParamsSafe(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 String[] queryParamsValues(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 String headers(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 Set<String> queryParams()
      Overrides:
      queryParams in class Request
      Returns:
      all query parameters
    • headers

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

      public 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 String toString()
      Overrides:
      toString in class Object
    • userAgent

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

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

      public 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 String protocol()
      Overrides:
      protocol in class Request
      Returns:
      Returns the name and version of the protocol the request uses
    • attribute

      public void attribute(String attribute, 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(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 Set<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()
      Overrides:
      queryMap in class Request
      Returns:
      the query map
    • queryMap

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

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

      public String cookie(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