Class Request
- java.lang.Object
-
- com.djrapitops.plan.delivery.web.resolver.request.Request
-
public final class Request extends java.lang.Object
Represents a HTTP request to use withResolver
.
-
-
Constructor Summary
Constructors Constructor Description Request(java.lang.String method, URIPath path, URIQuery query, WebUser user, java.util.Map<java.lang.String,java.lang.String> headers, byte[] requestBody)
Constructor.Request(java.lang.String method, java.lang.String target, WebUser user, java.util.Map<java.lang.String,java.lang.String> headers)
Special constructor that figures out URIPath and URIQuery from "/path/and?query=params" and has no request body.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<java.lang.String>
getHeader(java.lang.String key)
Get a header in the request.java.lang.String
getMethod()
Get HTTP method.URIPath
getPath()
Get the Requested path.URIQuery
getQuery()
Get the Request parameters.byte[]
getRequestBody()
Get the raw body, if present.java.util.Optional<WebUser>
getUser()
Get the user making the request.Request
omitFirstInPath()
java.lang.String
toString()
-
-
-
Constructor Detail
-
Request
public Request(java.lang.String method, URIPath path, URIQuery query, WebUser user, java.util.Map<java.lang.String,java.lang.String> headers, byte[] requestBody)
Constructor.- Parameters:
method
- HTTP method, GET, PUT, POST, etcpath
- Requested path /example/targetquery
- Request parameters ?param=value etcuser
- Web user doing the request (if authenticated)headers
- Request headers https://developer.mozilla.org/en-US/docs/Web/HTTP/HeadersrequestBody
- Raw body as bytes, if present
-
Request
public Request(java.lang.String method, java.lang.String target, WebUser user, java.util.Map<java.lang.String,java.lang.String> headers)
Special constructor that figures out URIPath and URIQuery from "/path/and?query=params" and has no request body.
-
-
Method Detail
-
getMethod
public java.lang.String getMethod()
Get HTTP method.- Returns:
- GET, PUT, POST, etc
-
getRequestBody
public byte[] getRequestBody()
Get the raw body, if present.- Returns:
- byte[].
-
getUser
public java.util.Optional<WebUser> getUser()
Get the user making the request.- Returns:
- the user if authentication is enabled
-
getHeader
public java.util.Optional<java.lang.String> getHeader(java.lang.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 java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-