java.lang.Object
com.djrapitops.plan.delivery.web.resolver.request.Request

public final class Request extends Object
Represents a HTTP request to use with Resolver.
  • Constructor Details

    • Request

      public Request(String method, URIPath path, URIQuery query, WebUser user, Map<String,String> headers, byte[] requestBody)
      Constructor.
      Parameters:
      method - HTTP method, GET, PUT, POST, etc
      path - Requested path /example/target
      query - Request parameters ?param=value etc
      user - Web user doing the request (if authenticated)
      headers - Request headers https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
      requestBody - Raw body as bytes, if present
    • Request

      public Request(String method, String target, WebUser user, Map<String,String> headers)
      Special constructor that figures out URIPath and URIQuery from "/path/and?query=params" and has no request body.
  • Method Details

    • getMethod

      public String getMethod()
      Get HTTP method.
      Returns:
      GET, PUT, POST, etc
    • getPath

      public URIPath getPath()
      Get the Requested path.
      Returns:
      URIPath.
    • getQuery

      public URIQuery getQuery()
      Get the Request parameters.
      Returns:
      URIQuery.
    • getRequestBody

      public byte[] getRequestBody()
      Get the raw body, if present.
      Returns:
      byte[].
    • getUser

      public Optional<WebUser> getUser()
      Get the user making the request.
      Returns:
      the user if authentication is enabled
    • getHeader

      public Optional<String> getHeader(String key)
      Get a header in the request.
      Parameters:
      key - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
      Returns:
      Value if it is present in the request.
    • omitFirstInPath

      public Request omitFirstInPath()
    • toString

      public String toString()
      Overrides:
      toString in class Object