Class THttpService
- java.lang.Object
-
- com.linecorp.armeria.common.util.AbstractUnwrappable<com.linecorp.armeria.server.Service<T_I,T_O>>
-
- com.linecorp.armeria.server.DecoratingService<com.linecorp.armeria.common.RpcRequest,com.linecorp.armeria.common.RpcResponse,com.linecorp.armeria.common.HttpRequest,com.linecorp.armeria.common.HttpResponse>
-
- com.linecorp.armeria.server.thrift.THttpService
-
- All Implemented Interfaces:
com.linecorp.armeria.common.util.Unwrappable,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.DecoratingService<com.linecorp.armeria.common.RpcRequest,com.linecorp.armeria.common.RpcResponse,com.linecorp.armeria.common.HttpRequest,com.linecorp.armeria.common.HttpResponse> implements com.linecorp.armeria.server.HttpServiceAnHttpServicethat handles a Thrift call.- See Also:
ThriftProtocolFactories
-
-
Method Summary
Modifier and Type Method Description Set<com.linecorp.armeria.common.SerializationFormat>allowedSerializationFormats()Returns the allowed serialization formats of this service.static THttpServiceBuilderbuilder()Creates a new instance ofTHttpServiceBuilderwhich can build an instance ofTHttpServicefluently.com.linecorp.armeria.common.SerializationFormatdefaultSerializationFormat()Returns the default serialization format of this service.Map<String,ThriftServiceEntry>entries()Returns the information about the Thrift services being served.static Function<? super com.linecorp.armeria.server.RpcService,THttpService>newDecorator()Creates a new decorator that supports all thrift protocols and defaults toTBinaryprotocol when the client doesn't specify one.static Function<? super com.linecorp.armeria.server.RpcService,THttpService>newDecorator(com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat)Creates a new decorator that supports all thrift protocols and defaults to the specifieddefaultSerializationFormatwhen the client doesn't specify one.static Function<? super com.linecorp.armeria.server.RpcService,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 specifieddefaultSerializationFormatwhen the client doesn't specify one.static Function<? super com.linecorp.armeria.server.RpcService,THttpService>newDecorator(com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, Iterable<com.linecorp.armeria.common.SerializationFormat> otherAllowedSerializationFormats)Creates a new decorator that supports the protocols specified inallowedSerializationFormatsand defaults to the specifieddefaultSerializationFormatwhen the client doesn't specify one.static THttpServiceof(Object implementation)Creates a newTHttpServicewith the specified service implementation, supporting all thrift protocols and defaulting toTBinaryprotocol when the client doesn't specify one.static THttpServiceof(Object implementation, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat)Creates a newTHttpServicewith the specified service implementation, supporting all thrift protocols and defaulting to the specifieddefaultSerializationFormatwhen the client doesn't specify one.static THttpServiceof(Map<String,?> implementations)Deprecated.Usebuilder().static THttpServiceof(Map<String,?> implementations, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat)Deprecated.Usebuilder().static THttpServiceofFormats(Object implementation, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, com.linecorp.armeria.common.SerializationFormat... otherAllowedSerializationFormats)Creates a newTHttpServicewith the specified service implementation, supporting only the formats specified and defaulting to the specifieddefaultSerializationFormatwhen the client doesn't specify one.static THttpServiceofFormats(Object implementation, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, Iterable<com.linecorp.armeria.common.SerializationFormat> otherAllowedSerializationFormats)Creates a newTHttpServicewith the specified service implementation, supporting the protocols specified inallowedSerializationFormatsand defaulting to the specifieddefaultSerializationFormatwhen the client doesn't specify one.static THttpServiceofFormats(Map<String,?> implementations, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, com.linecorp.armeria.common.SerializationFormat... otherAllowedSerializationFormats)Deprecated.Usebuilder().static THttpServiceofFormats(Map<String,?> implementations, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, Iterable<com.linecorp.armeria.common.SerializationFormat> otherAllowedSerializationFormats)Deprecated.Usebuilder().com.linecorp.armeria.common.HttpResponseserve(com.linecorp.armeria.server.ServiceRequestContext ctx, com.linecorp.armeria.common.HttpRequest req)-
Methods inherited from class com.linecorp.armeria.server.DecoratingService
serviceAdded, shouldCachePath
-
Methods inherited from class com.linecorp.armeria.common.util.AbstractUnwrappable
as, delegate, toString
-
-
-
-
Method Detail
-
builder
public static THttpServiceBuilder builder()
Creates a new instance ofTHttpServiceBuilderwhich can build an instance ofTHttpServicefluently.The default SerializationFormat
ThriftSerializationFormats.BINARYwill be used when client does not specify one in the request, but also supportsThriftSerializationFormats.values().Currently, the only way to specify a serialization format is by using the HTTP session protocol and setting the
"Content-Type"header to the appropriateSerializationFormat.mediaType().
-
of
public static THttpService of(Object implementation)
Creates a newTHttpServicewith the specified service implementation, supporting all thrift protocols and defaulting toTBinaryprotocol 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 appropriateSerializationFormat.mediaType().- Parameters:
implementation- an implementation of*.Ifaceor*.AsyncIfaceservice interface generated by the Apache Thrift compiler
-
of
@Deprecated public static THttpService of(Map<String,?> implementations)
Deprecated.Usebuilder().Creates a new multiplexedTHttpServicewith the specified service implementations, supporting all thrift protocols and defaulting toTBinaryprotocol 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 appropriateSerializationFormat.mediaType().- Parameters:
implementations- aMapwhose key is service name and value is the implementation of*.Ifaceor*.AsyncIfaceservice interface generated by the Apache Thrift compiler
-
of
public static THttpService of(Object implementation, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat)
Creates a newTHttpServicewith the specified service implementation, supporting all thrift protocols and defaulting to the specifieddefaultSerializationFormatwhen 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 appropriateSerializationFormat.mediaType().- Parameters:
implementation- an implementation of*.Ifaceor*.AsyncIfaceservice interface generated by the Apache Thrift compilerdefaultSerializationFormat- the default serialization format to use when not specified by the client
-
of
@Deprecated public static THttpService of(Map<String,?> implementations, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat)
Deprecated.Usebuilder().Creates a new multiplexedTHttpServicewith the specified service implementations, supporting all thrift protocols and defaulting to the specifieddefaultSerializationFormatwhen 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 appropriateSerializationFormat.mediaType().- Parameters:
implementations- aMapwhose key is service name and value is the implementation of*.Ifaceor*.AsyncIfaceservice interface generated by the Apache Thrift compilerdefaultSerializationFormat- 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 newTHttpServicewith the specified service implementation, supporting only the formats specified and defaulting to the specifieddefaultSerializationFormatwhen 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 appropriateSerializationFormat.mediaType().- Parameters:
implementation- an implementation of*.Ifaceor*.AsyncIfaceservice interface generated by the Apache Thrift compilerdefaultSerializationFormat- the default serialization format to use when not specified by the clientotherAllowedSerializationFormats- other serialization formats that should be supported by this service in addition to the default
-
ofFormats
@Deprecated public static THttpService ofFormats(Map<String,?> implementations, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, com.linecorp.armeria.common.SerializationFormat... otherAllowedSerializationFormats)
Deprecated.Usebuilder().Creates a new multiplexedTHttpServicewith the specified service implementations, supporting only the formats specified and defaulting to the specifieddefaultSerializationFormatwhen 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 appropriateSerializationFormat.mediaType().- Parameters:
implementations- aMapwhose key is service name and value is the implementation of*.Ifaceor*.AsyncIfaceservice interface generated by the Apache Thrift compilerdefaultSerializationFormat- the default serialization format to use when not specified by the clientotherAllowedSerializationFormats- 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 newTHttpServicewith the specified service implementation, supporting the protocols specified inallowedSerializationFormatsand defaulting to the specifieddefaultSerializationFormatwhen 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 appropriateSerializationFormat.mediaType().- Parameters:
implementation- an implementation of*.Ifaceor*.AsyncIfaceservice interface generated by the Apache Thrift compilerdefaultSerializationFormat- the default serialization format to use when not specified by the clientotherAllowedSerializationFormats- other serialization formats that should be supported by this service in addition to the default
-
ofFormats
@Deprecated public static THttpService ofFormats(Map<String,?> implementations, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, Iterable<com.linecorp.armeria.common.SerializationFormat> otherAllowedSerializationFormats)
Deprecated.Usebuilder().Creates a new multiplexedTHttpServicewith the specified service implementations, supporting the protocols specified inallowedSerializationFormatsand defaulting to the specifieddefaultSerializationFormatwhen 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 appropriateSerializationFormat.mediaType().- Parameters:
implementations- aMapwhose key is service name and value is the implementation of*.Ifaceor*.AsyncIfaceservice interface generated by the Apache Thrift compilerdefaultSerializationFormat- the default serialization format to use when not specified by the clientotherAllowedSerializationFormats- other serialization formats that should be supported by this service in addition to the default
-
newDecorator
public static Function<? super com.linecorp.armeria.server.RpcService,THttpService> newDecorator()
Creates a new decorator that supports all thrift protocols and defaults toTBinaryprotocol 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 appropriateSerializationFormat.mediaType().
-
newDecorator
public static Function<? super com.linecorp.armeria.server.RpcService,THttpService> newDecorator(com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat)
Creates a new decorator that supports all thrift protocols and defaults to the specifieddefaultSerializationFormatwhen 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 appropriateSerializationFormat.mediaType().- Parameters:
defaultSerializationFormat- the default serialization format to use when not specified by the client
-
newDecorator
public static Function<? super com.linecorp.armeria.server.RpcService,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 specifieddefaultSerializationFormatwhen 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 appropriateSerializationFormat.mediaType().- Parameters:
defaultSerializationFormat- the default serialization format to use when not specified by the clientotherAllowedSerializationFormats- other serialization formats that should be supported by this service in addition to the default
-
newDecorator
public static Function<? super com.linecorp.armeria.server.RpcService,THttpService> newDecorator(com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, Iterable<com.linecorp.armeria.common.SerializationFormat> otherAllowedSerializationFormats)
Creates a new decorator that supports the protocols specified inallowedSerializationFormatsand defaults to the specifieddefaultSerializationFormatwhen 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 appropriateSerializationFormat.mediaType().- Parameters:
defaultSerializationFormat- the default serialization format to use when not specified by the clientotherAllowedSerializationFormats- 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
Mapwhose 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.
-
serve
public com.linecorp.armeria.common.HttpResponse serve(com.linecorp.armeria.server.ServiceRequestContext ctx, com.linecorp.armeria.common.HttpRequest req) throws Exception- Specified by:
servein interfacecom.linecorp.armeria.server.HttpService- Specified by:
servein interfacecom.linecorp.armeria.server.Service<com.linecorp.armeria.common.HttpRequest,com.linecorp.armeria.common.HttpResponse>- Throws:
Exception
-
-