Class HttpContext.Request

  • Enclosing class:
    HttpContext

    public static class HttpContext.Request
    extends Object
    Provides a HTTP request object.
    • Constructor Detail

      • Request

        public Request​(String method,
                       String path,
                       Map<String,​List<String>> headers,
                       Map<String,​List<String>> queryParams,
                       String mimeType,
                       byte[] data,
                       Map<String,​String> pathParams,
                       Map<String,​Object> extras)
        Create a new Request object.
        Parameters:
        method - the method of the HTTP request
        path - the path of the HTTP request
        headers - the headers of the HTTP request
        queryParams - the query parameters of the HTTP request
        mimeType - the request mime-type
        data - the HTTP body data
        pathParams - the request URL path parameters
        extras - the request extra attributes
    • Method Detail

      • getMethod

        public String getMethod()
        Return the HTTP request method [ GET | POST | PUT | DELETE ].
        Returns:
        the HTTP request method
      • getPath

        public String getPath()
        Return HTTP request path, or an empty string if not defined.
        Returns:
        HTTP request path, or an empty string if not defined
      • getHeader

        public String getHeader​(String name)
        Return the first HTTP header value for the given name, or null not found.
        Parameters:
        name - the HTTP header name (required)
        Returns:
        the first HTTP header value for the given name, or null not found.
      • getHeaders

        public Map<String,​List<String>> getHeaders()
        Return an immutable map of HTTP request header values. If no headers are present an empty map will be returned.
        Returns:
        map of HTTP request header values
      • getQueryParam

        public String getQueryParam​(String name)
        Return the first HTTP query parameter value for the given name, or null not found.
        Parameters:
        name - the HTTP query parameter name (required)
        Returns:
        the first HTTP query parameter value for the given name, or null not found.
      • getQueryParams

        public Map<String,​List<String>> getQueryParams()
        Return an immutable map of HTTP request query parameters. If no parameters are present then an empty map will be returned.
        Returns:
        an immutable map of HTTP request query parameter values
      • getMimeType

        public String getMimeType()
        Return the HTTP request MIME Type or "Content-Type" header value, or an empty string if not defined.
        Returns:
        the HTTP request MIME Type or "Content-Type" header value
      • getData

        public byte[] getData()
        Return the HTTP request body data. If no data is present a zero length array will be returned.
        Returns:
        the HTTP request body data
      • getDataAsText

        public String getDataAsText()
        Return the HTTP request body data (UTF-8 encoded) as text, or an empty string if not defined.
        Returns:
        the HTTP request body data (UTF-8 encoded) as text, or an empty string if not defined.
      • getPathParams

        public Map<String,​String> getPathParams()
        Return the request URL path params map. The request pathParams map provides support for custom middleware enhancements to the context request.
        Returns:
        the request URL path parameters, or an empty map if not defined
      • getExtras

        public Map<String,​Object> getExtras()
        Return the request extras map. The request extras map provides support for custom middleware enhancement to the context request.
        Returns:
        the request extras attributes, or an empty map if not defined
      • toString

        public String toString()
        Return the string representation of this object.
        Overrides:
        toString in class Object
        Returns:
        the string representation of this object