Package org.yamcs.http
Class RouteContext
java.lang.Object
org.yamcs.http.Context
org.yamcs.http.RouteContext
-
Field Summary
Modifier and TypeFieldDescriptionio.netty.handler.codec.http.FullHttpRequest
final io.netty.handler.codec.http.HttpRequest
The Netty HTTP request for an RPC call.Fields inherited from class org.yamcs.http.Context
api, fieldMask, log, nettyContext, reverseLookup, statusCode, txSize, user
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 request<T extends com.google.protobuf.Message.Builder>
TgetBodyAsMessage
(T builder) Deserializes the incoming message extracted from the body.int
com.google.protobuf.Descriptors.MethodDescriptor
getRouteParam
(String name) getURI()
boolean
hasBody()
boolean
hasRouteParam
(String name) boolean
Methods inherited from class org.yamcs.http.Context
addTransferredSize, checkAnyOfSystemPrivileges, checkObjectPrivileges, checkObjectPrivileges, checkSystemPrivilege, getApi, getFieldMask, getId, getRequestPrototype, getResponsePrototype, getStatusCode, getTransferredSize, isClientStreaming, isServerStreaming, parseJson, printJson, reportStatusCode, toString
-
Field Details
-
nettyRequest
public final io.netty.handler.codec.http.HttpRequest nettyRequestThe 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 Details
-
getClientAddress
- Overrides:
getClientAddress
in classContext
-
getMethod
public com.google.protobuf.Descriptors.MethodDescriptor getMethod() -
getBodySpecifier
-
getFieldMaskRoot
-
getMaxBodySize
public int getMaxBodySize() -
getURI
-
hasRouteParam
-
getRouteParam
-
hasBody
public boolean hasBody() -
isOffloaded
public boolean isOffloaded() -
getLogFormat
-
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
-
getBody
public io.netty.buffer.ByteBuf getBody()returns the body of the http request -
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
-