Class THttpService

  • All Implemented Interfaces:
    com.linecorp.armeria.server.HttpService, com.linecorp.armeria.server.Service<com.linecorp.armeria.common.HttpRequest,com.linecorp.armeria.common.HttpResponse>

    public final class THttpService
    extends com.linecorp.armeria.server.AbstractHttpService
    A Service that handles a Thrift call.
    See Also:
    ThriftProtocolFactories
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Set<com.linecorp.armeria.common.SerializationFormat> allowedSerializationFormats()
      Returns the allowed serialization formats of this service.
      com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat()
      Returns the default serialization format of this service.
      protected com.linecorp.armeria.common.HttpResponse doPost​(com.linecorp.armeria.server.ServiceRequestContext ctx, com.linecorp.armeria.common.HttpRequest req)  
      Map<String,ThriftServiceEntry> entries()
      Returns the information about the Thrift services being served.
      static Function<com.linecorp.armeria.server.Service<com.linecorp.armeria.common.RpcRequest,com.linecorp.armeria.common.RpcResponse>,THttpService> newDecorator()
      Creates a new decorator that supports all thrift protocols and defaults to TBinary protocol when the client doesn't specify one.
      static Function<com.linecorp.armeria.server.Service<com.linecorp.armeria.common.RpcRequest,com.linecorp.armeria.common.RpcResponse>,THttpService> newDecorator​(com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat)
      Creates a new decorator that supports all thrift protocols and defaults to the specified defaultSerializationFormat when the client doesn't specify one.
      static Function<com.linecorp.armeria.server.Service<com.linecorp.armeria.common.RpcRequest,com.linecorp.armeria.common.RpcResponse>,THttpService> newDecorator​(com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, com.linecorp.armeria.common.SerializationFormat... otherAllowedSerializationFormats)
      Creates a new decorator that supports only the formats specified and defaults to the specified defaultSerializationFormat when the client doesn't specify one.
      static Function<com.linecorp.armeria.server.Service<com.linecorp.armeria.common.RpcRequest,com.linecorp.armeria.common.RpcResponse>,THttpService> newDecorator​(com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, Iterable<com.linecorp.armeria.common.SerializationFormat> otherAllowedSerializationFormats)
      Creates a new decorator that supports the protocols specified in allowedSerializationFormats and defaults to the specified defaultSerializationFormat when the client doesn't specify one.
      static THttpService of​(Object implementation)
      Creates a new THttpService with the specified service implementation, supporting all thrift protocols and defaulting to TBinary protocol when the client doesn't specify one.
      static THttpService of​(Object implementation, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat)
      Creates a new THttpService with the specified service implementation, supporting all thrift protocols and defaulting to the specified defaultSerializationFormat when the client doesn't specify one.
      static THttpService of​(Map<String,?> implementations)
      Creates a new multiplexed THttpService with the specified service implementations, supporting all thrift protocols and defaulting to TBinary protocol when the client doesn't specify one.
      static THttpService of​(Map<String,?> implementations, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat)
      Creates a new multiplexed THttpService with the specified service implementations, supporting all thrift protocols and defaulting to the specified defaultSerializationFormat when the client doesn't specify one.
      static THttpService ofFormats​(Object implementation, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, com.linecorp.armeria.common.SerializationFormat... otherAllowedSerializationFormats)
      Creates a new THttpService with the specified service implementation, supporting only the formats specified and defaulting to the specified defaultSerializationFormat when the client doesn't specify one.
      static THttpService ofFormats​(Object implementation, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, Iterable<com.linecorp.armeria.common.SerializationFormat> otherAllowedSerializationFormats)
      Creates a new THttpService with the specified service implementation, supporting the protocols specified in allowedSerializationFormats and defaulting to the specified defaultSerializationFormat when the client doesn't specify one.
      static THttpService ofFormats​(Map<String,?> implementations, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, com.linecorp.armeria.common.SerializationFormat... otherAllowedSerializationFormats)
      Creates a new multiplexed THttpService with the specified service implementations, supporting only the formats specified and defaulting to the specified defaultSerializationFormat when the client doesn't specify one.
      static THttpService ofFormats​(Map<String,?> implementations, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, Iterable<com.linecorp.armeria.common.SerializationFormat> otherAllowedSerializationFormats)
      Creates a new multiplexed THttpService with the specified service implementations, supporting the protocols specified in allowedSerializationFormats and defaulting to the specified defaultSerializationFormat when the client doesn't specify one.
      • Methods inherited from class com.linecorp.armeria.server.AbstractHttpService

        doDelete, doDelete, doGet, doGet, doHead, doHead, doOptions, doOptions, doPatch, doPatch, doPost, doPut, doPut, doTrace, doTrace, serve
      • Methods inherited from interface com.linecorp.armeria.server.Service

        as, decorate, decorate, decorate, serviceAdded, shouldCachePath
    • Method Detail

      • of

        public static THttpService of​(Object implementation)
        Creates a new THttpService with the specified service implementation, supporting all thrift protocols and defaulting to TBinary protocol when the client doesn't specify one.

        Currently, the only way to specify a serialization format is by using the HTTP session protocol and setting the Content-Type header to the appropriate SerializationFormat.mediaType().

        Parameters:
        implementation - an implementation of *.Iface or *.AsyncIface service interface generated by the Apache Thrift compiler
      • of

        public static THttpService of​(Map<String,?> implementations)
        Creates a new multiplexed THttpService with the specified service implementations, supporting all thrift protocols and defaulting to TBinary protocol when the client doesn't specify one.

        Currently, the only way to specify a serialization format is by using the HTTP session protocol and setting the Content-Type header to the appropriate SerializationFormat.mediaType().

        Parameters:
        implementations - a Map whose key is service name and value is the implementation of *.Iface or *.AsyncIface service interface generated by the Apache Thrift compiler
      • of

        public static THttpService of​(Object implementation,
                                      com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat)
        Creates a new THttpService with the specified service implementation, supporting all thrift protocols and defaulting to the specified defaultSerializationFormat when the client doesn't specify one.

        Currently, the only way to specify a serialization format is by using the HTTP session protocol and setting the Content-Type header to the appropriate SerializationFormat.mediaType().

        Parameters:
        implementation - an implementation of *.Iface or *.AsyncIface service interface generated by the Apache Thrift compiler
        defaultSerializationFormat - the default serialization format to use when not specified by the client
      • of

        public static THttpService of​(Map<String,?> implementations,
                                      com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat)
        Creates a new multiplexed THttpService with the specified service implementations, supporting all thrift protocols and defaulting to the specified defaultSerializationFormat when the client doesn't specify one.

        Currently, the only way to specify a serialization format is by using the HTTP session protocol and setting the Content-Type header to the appropriate SerializationFormat.mediaType().

        Parameters:
        implementations - a Map whose key is service name and value is the implementation of *.Iface or *.AsyncIface service interface generated by the Apache Thrift compiler
        defaultSerializationFormat - the default serialization format to use when not specified by the client
      • ofFormats

        public static THttpService ofFormats​(Object implementation,
                                             com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat,
                                             com.linecorp.armeria.common.SerializationFormat... otherAllowedSerializationFormats)
        Creates a new THttpService with the specified service implementation, supporting only the formats specified and defaulting to the specified defaultSerializationFormat when the client doesn't specify one.

        Currently, the only way to specify a serialization format is by using the HTTP session protocol and setting the Content-Type header to the appropriate SerializationFormat.mediaType().

        Parameters:
        implementation - an implementation of *.Iface or *.AsyncIface service interface generated by the Apache Thrift compiler
        defaultSerializationFormat - the default serialization format to use when not specified by the client
        otherAllowedSerializationFormats - other serialization formats that should be supported by this service in addition to the default
      • ofFormats

        public static THttpService ofFormats​(Map<String,?> implementations,
                                             com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat,
                                             com.linecorp.armeria.common.SerializationFormat... otherAllowedSerializationFormats)
        Creates a new multiplexed THttpService with the specified service implementations, supporting only the formats specified and defaulting to the specified defaultSerializationFormat when the client doesn't specify one.

        Currently, the only way to specify a serialization format is by using the HTTP session protocol and setting the Content-Type header to the appropriate SerializationFormat.mediaType().

        Parameters:
        implementations - a Map whose key is service name and value is the implementation of *.Iface or *.AsyncIface service interface generated by the Apache Thrift compiler
        defaultSerializationFormat - the default serialization format to use when not specified by the client
        otherAllowedSerializationFormats - other serialization formats that should be supported by this service in addition to the default
      • ofFormats

        public static THttpService ofFormats​(Object implementation,
                                             com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat,
                                             Iterable<com.linecorp.armeria.common.SerializationFormat> otherAllowedSerializationFormats)
        Creates a new THttpService with the specified service implementation, supporting the protocols specified in allowedSerializationFormats and defaulting to the specified defaultSerializationFormat when the client doesn't specify one.

        Currently, the only way to specify a serialization format is by using the HTTP session protocol and setting the Content-Type header to the appropriate SerializationFormat.mediaType().

        Parameters:
        implementation - an implementation of *.Iface or *.AsyncIface service interface generated by the Apache Thrift compiler
        defaultSerializationFormat - the default serialization format to use when not specified by the client
        otherAllowedSerializationFormats - other serialization formats that should be supported by this service in addition to the default
      • ofFormats

        public static THttpService ofFormats​(Map<String,?> implementations,
                                             com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat,
                                             Iterable<com.linecorp.armeria.common.SerializationFormat> otherAllowedSerializationFormats)
        Creates a new multiplexed THttpService with the specified service implementations, supporting the protocols specified in allowedSerializationFormats and defaulting to the specified defaultSerializationFormat when the client doesn't specify one.

        Currently, the only way to specify a serialization format is by using the HTTP session protocol and setting the Content-Type header to the appropriate SerializationFormat.mediaType().

        Parameters:
        implementations - a Map whose key is service name and value is the implementation of *.Iface or *.AsyncIface service interface generated by the Apache Thrift compiler
        defaultSerializationFormat - the default serialization format to use when not specified by the client
        otherAllowedSerializationFormats - other serialization formats that should be supported by this service in addition to the default
      • newDecorator

        public static Function<com.linecorp.armeria.server.Service<com.linecorp.armeria.common.RpcRequest,com.linecorp.armeria.common.RpcResponse>,THttpService> newDecorator()
        Creates a new decorator that supports all thrift protocols and defaults to TBinary protocol when the client doesn't specify one.

        Currently, the only way to specify a serialization format is by using the HTTP session protocol and setting the Content-Type header to the appropriate SerializationFormat.mediaType().

      • newDecorator

        public static Function<com.linecorp.armeria.server.Service<com.linecorp.armeria.common.RpcRequest,com.linecorp.armeria.common.RpcResponse>,THttpService> newDecorator​(com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat)
        Creates a new decorator that supports all thrift protocols and defaults to the specified defaultSerializationFormat when the client doesn't specify one. Currently, the only way to specify a serialization format is by using the HTTP session protocol and setting the Content-Type header to the appropriate SerializationFormat.mediaType().
        Parameters:
        defaultSerializationFormat - the default serialization format to use when not specified by the client
      • newDecorator

        public static Function<com.linecorp.armeria.server.Service<com.linecorp.armeria.common.RpcRequest,com.linecorp.armeria.common.RpcResponse>,THttpService> newDecorator​(com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat,
                                                                                                                                                                              com.linecorp.armeria.common.SerializationFormat... otherAllowedSerializationFormats)
        Creates a new decorator that supports only the formats specified and defaults to the specified defaultSerializationFormat when the client doesn't specify one. Currently, the only way to specify a serialization format is by using the HTTP session protocol and setting the Content-Type header to the appropriate SerializationFormat.mediaType().
        Parameters:
        defaultSerializationFormat - the default serialization format to use when not specified by the client
        otherAllowedSerializationFormats - other serialization formats that should be supported by this service in addition to the default
      • newDecorator

        public static Function<com.linecorp.armeria.server.Service<com.linecorp.armeria.common.RpcRequest,com.linecorp.armeria.common.RpcResponse>,THttpService> newDecorator​(com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat,
                                                                                                                                                                              Iterable<com.linecorp.armeria.common.SerializationFormat> otherAllowedSerializationFormats)
        Creates a new decorator that supports the protocols specified in allowedSerializationFormats and defaults to the specified defaultSerializationFormat when the client doesn't specify one. Currently, the only way to specify a serialization format is by using the HTTP session protocol and setting the Content-Type header to the appropriate SerializationFormat.mediaType().
        Parameters:
        defaultSerializationFormat - the default serialization format to use when not specified by the client
        otherAllowedSerializationFormats - other serialization formats that should be supported by this service in addition to the default
      • entries

        public Map<String,ThriftServiceEntry> entries()
        Returns the information about the Thrift services being served.
        Returns:
        a Map whose key is a service name, which could be an empty string if this service is not multiplexed
      • allowedSerializationFormats

        public Set<com.linecorp.armeria.common.SerializationFormat> allowedSerializationFormats()
        Returns the allowed serialization formats of this service.
      • defaultSerializationFormat

        public com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat()
        Returns the default serialization format of this service.
      • doPost

        protected com.linecorp.armeria.common.HttpResponse doPost​(com.linecorp.armeria.server.ServiceRequestContext ctx,
                                                                  com.linecorp.armeria.common.HttpRequest req)
        Overrides:
        doPost in class com.linecorp.armeria.server.AbstractHttpService