Package org.yamcs.http
Class RouteContext
- java.lang.Object
-
- org.yamcs.http.Context
-
- org.yamcs.http.RouteContext
-
public class RouteContext extends Context
-
-
Field Summary
Fields Modifier and Type Field Description io.netty.handler.codec.http.FullHttpRequest
fullNettyRequest
io.netty.handler.codec.http.HttpRequest
nettyRequest
The Netty HTTP request for an RPC call.-
Fields inherited from class org.yamcs.http.Context
api, log, nettyContext, statusCode, txSize, user
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MediaType
deriveTargetContentType()
static MediaType
deriveTargetContentType(io.netty.handler.codec.http.HttpRequest httpRequest)
Derives an applicable content type for the output.io.netty.buffer.ByteBuf
getBody()
returns the body of the http requestInputStream
getBodyAsInputStream()
<T extends com.google.protobuf.Message.Builder>
TgetBodyAsMessage(T builder)
Deserializes the incoming message extracted from the body.String
getBodySpecifier()
String
getClientAddress()
int
getMaxBodySize()
com.google.protobuf.Descriptors.MethodDescriptor
getMethod()
String
getRouteParam(String name)
String
getURI()
boolean
hasBody()
boolean
hasRouteParam(String name)
boolean
isOffloaded()
-
Methods inherited from class org.yamcs.http.Context
addTransferredSize, checkObjectPrivileges, checkObjectPrivileges, checkSystemPrivilege, getApi, getId, getRequestPrototype, getResponsePrototype, getStatusCode, getTransferredSize, isClientStreaming, isServerStreaming, parseJson, printJson, reportStatusCode, toString
-
-
-
-
Field Detail
-
nettyRequest
public final io.netty.handler.codec.http.HttpRequest nettyRequest
The Netty HTTP request for an RPC call. In general RPC implementations should avoid using this object. It is exposed only because we need it for some HTTP-specific functionalities that are not covered by our RPC implementation (e.g. multipart uploading)
-
fullNettyRequest
public io.netty.handler.codec.http.FullHttpRequest fullNettyRequest
-
-
Method Detail
-
getClientAddress
public String getClientAddress()
- Overrides:
getClientAddress
in classContext
-
getMethod
public com.google.protobuf.Descriptors.MethodDescriptor getMethod()
-
getBodySpecifier
public String getBodySpecifier()
-
getMaxBodySize
public int getMaxBodySize()
-
getURI
public String getURI()
-
hasRouteParam
public boolean hasRouteParam(String name)
-
hasBody
public boolean hasBody()
-
isOffloaded
public boolean isOffloaded()
-
getBodyAsMessage
public <T extends com.google.protobuf.Message.Builder> T getBodyAsMessage(T builder) throws BadRequestException
Deserializes the incoming message extracted from the body. This does not care about what the HTTP method is. Any required checks should be done elsewhere.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
getBodyAsInputStream()
.- Throws:
BadRequestException
-
getBodyAsInputStream
public InputStream getBodyAsInputStream()
-
getBody
public io.netty.buffer.ByteBuf getBody()
returns the body of the http request
-
deriveTargetContentType
public MediaType deriveTargetContentType()
-
deriveTargetContentType
public static MediaType deriveTargetContentType(io.netty.handler.codec.http.HttpRequest httpRequest)
Derives an applicable content type for the output. This tries to match JSON or BINARY media types with the ACCEPT header, else it will revert to the (derived) source content type.- Returns:
- the content type that will be used for the response message
-
-