public class RestRequest extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
RestRequest.IntervalResult |
| Constructor and Description |
|---|
RestRequest(io.netty.channel.ChannelHandlerContext channelHandlerContext,
io.netty.handler.codec.http.FullHttpRequest httpRequest,
io.netty.handler.codec.http.QueryStringDecoder qsDecoder,
AuthenticationToken token) |
| Modifier and Type | Method and Description |
|---|---|
void |
addTransferredSize(long numBytes)
add numBytes to the transferred size
|
boolean |
asksDescending(boolean descendByDefault)
Returns true if the request specifies descending by use of the query string paramter 'order=desc'
|
boolean |
asksFor(MediaType mediaType)
Matches the content type on either the Accept header or a 'format' query param.
|
InputStream |
bodyAsInputStream() |
<T extends com.google.protobuf.Message.Builder> |
bodyAsMessage(T builder)
Deserializes the incoming message extracted from the body.
|
MediaType |
deriveSourceContentType() |
MediaType |
deriveTargetContentType()
Derives an applicable content type for the output.
|
static MediaType |
deriveTargetContentType(io.netty.handler.codec.http.HttpRequest httpRequest) |
AuthenticationToken |
getAuthToken() |
String |
getBaseURL() |
io.netty.channel.ChannelHandlerContext |
getChannelHandlerContext() |
CompletableFuture<Void> |
getCompletableFuture()
When the request is finished, the CompleteableFuture has to be used to signal the end.
|
long |
getDateRouteParam(String name) |
String |
getFullPathWithoutQueryString() |
String |
getHeader(io.netty.util.AsciiString name) |
io.netty.handler.codec.http.HttpRequest |
getHttpRequest() |
int |
getIntegerRouteParam(String name) |
long |
getLongRouteParam(String name) |
String |
getQueryParameter(String name) |
String |
getQueryParameter(String name,
String defaultValue) |
boolean |
getQueryParameterAsBoolean(String name) |
boolean |
getQueryParameterAsBoolean(String name,
boolean defaultValue) |
long |
getQueryParameterAsDate(String name) |
long |
getQueryParameterAsDate(String name,
long defaultValue) |
int |
getQueryParameterAsInt(String name) |
int |
getQueryParameterAsInt(String name,
int defaultValue) |
long |
getQueryParameterAsLong(String name) |
long |
getQueryParameterAsLong(String name,
long defaultValue) |
List<String> |
getQueryParameterList(String name) |
List<String> |
getQueryParameterList(String name,
List<String> defaultList) |
Map<String,List<String>> |
getQueryParameters() |
int |
getRequestId() |
String |
getRouteParam(String name) |
long |
getTransferredSize()
Get the number of bytes transferred as the result of the REST call.
|
String |
getUsername()
Returns the username of the authenticated user.
|
boolean |
hasBody() |
boolean |
hasHeader(String name) |
boolean |
hasQueryParameter(String name) |
boolean |
hasRouteParam(String name) |
boolean |
isSSL() |
static long |
parseTime(String datetime)
Interprets the provided string as either an instant, or an ISO 8601 string and returns it as an instant of type
long
|
RestRequest.IntervalResult |
scanForInterval() |
public RestRequest(io.netty.channel.ChannelHandlerContext channelHandlerContext,
io.netty.handler.codec.http.FullHttpRequest httpRequest,
io.netty.handler.codec.http.QueryStringDecoder qsDecoder,
AuthenticationToken token)
public boolean hasRouteParam(String name)
public int getRequestId()
public long getLongRouteParam(String name) throws BadRequestException
BadRequestExceptionpublic int getIntegerRouteParam(String name) throws BadRequestException
BadRequestExceptionpublic long getDateRouteParam(String name) throws BadRequestException
BadRequestExceptionpublic String getFullPathWithoutQueryString()
public boolean hasHeader(String name)
public String getHeader(io.netty.util.AsciiString name)
public boolean asksFor(MediaType mediaType)
public String getUsername()
Privilege.getDefaultUser() if the user is not
authenticated.public AuthenticationToken getAuthToken()
public boolean hasQueryParameter(String name)
public List<String> getQueryParameterList(String name, List<String> defaultList)
public String getQueryParameter(String name, String defaultValue) throws BadRequestException
BadRequestExceptionpublic int getQueryParameterAsInt(String name) throws BadRequestException
BadRequestExceptionpublic int getQueryParameterAsInt(String name, int defaultValue) throws BadRequestException
BadRequestExceptionpublic long getQueryParameterAsLong(String name) throws BadRequestException
BadRequestExceptionpublic long getQueryParameterAsLong(String name, long defaultValue) throws BadRequestException
BadRequestExceptionpublic long getQueryParameterAsDate(String name) throws BadRequestException
BadRequestExceptionpublic long getQueryParameterAsDate(String name, long defaultValue) throws BadRequestException
BadRequestExceptionpublic boolean getQueryParameterAsBoolean(String name)
public boolean getQueryParameterAsBoolean(String name, boolean defaultValue)
public boolean isSSL()
public io.netty.channel.ChannelHandlerContext getChannelHandlerContext()
public io.netty.handler.codec.http.HttpRequest getHttpRequest()
public boolean hasBody()
public <T extends com.google.protobuf.Message.Builder> T bodyAsMessage(T builder)
throws BadRequestException
This method is only able to read JSON or Protobuf, the two auto-supported serialization mechanisms. If a certain
operation needs to read anything else, it should check for that itself, and then use
bodyAsInputStream().
BadRequestExceptionpublic InputStream bodyAsInputStream()
public MediaType deriveSourceContentType()
MediaType.getContentType(HttpRequest)public MediaType deriveTargetContentType()
public static MediaType deriveTargetContentType(io.netty.handler.codec.http.HttpRequest httpRequest)
public String getBaseURL()
public CompletableFuture<Void> getCompletableFuture()
public long getTransferredSize()
public void addTransferredSize(long numBytes)
numBytes - public boolean asksDescending(boolean descendByDefault)
throws HttpException
HttpExceptionpublic static long parseTime(String datetime)
public RestRequest.IntervalResult scanForInterval() throws HttpException
HttpExceptionCopyright © 2018 Space Applications Services. All rights reserved.