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.FullHttpRequestfullNettyRequestio.netty.handler.codec.http.HttpRequestnettyRequestThe 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 MediaTypederiveTargetContentType()static MediaTypederiveTargetContentType(io.netty.handler.codec.http.HttpRequest httpRequest)Derives an applicable content type for the output.io.netty.buffer.ByteBufgetBody()returns the body of the http requestInputStreamgetBodyAsInputStream()<T extends com.google.protobuf.Message.Builder>
TgetBodyAsMessage(T builder)Deserializes the incoming message extracted from the body.StringgetBodySpecifier()StringgetClientAddress()intgetMaxBodySize()com.google.protobuf.Descriptors.MethodDescriptorgetMethod()StringgetRouteParam(String name)StringgetURI()booleanhasBody()booleanhasRouteParam(String name)booleanisOffloaded()-
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:
getClientAddressin 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 BadRequestExceptionDeserializes 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
-
-