Class RouteContext


  • public class RouteContext
    extends Context
    • 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

      • getMethod

        public com.google.protobuf.Descriptors.MethodDescriptor getMethod()
        Specified by:
        getMethod in class Context
      • getBodySpecifier

        public String getBodySpecifier()
      • getMaxBodySize

        public int getMaxBodySize()
      • getURI

        public String getURI()
      • hasRouteParam

        public boolean hasRouteParam​(String name)
      • getRouteParam

        public String getRouteParam​(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