Class 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.HttpService
HttpService that handles a Thrift call.- See Also:
ThriftProtocolFactories
-
Method Summary
Modifier and Type Method Description static THttpServiceBuilderbuilder()Creates a new instance ofTHttpServiceBuilderwhich can build an instance ofTHttpServicefluently.com.linecorp.armeria.common.SerializationFormatdefaultSerializationFormat()Returns the defaultSerializationFormatof 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... otherSupportedSerializationFormats)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> otherSupportedSerializationFormats)Creates a new decorator that supports the protocols specified inotherSupportedSerializationFormatsand 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 THttpServiceofFormats(Object implementation, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, com.linecorp.armeria.common.SerializationFormat... otherSupportedSerializationFormats)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> otherSupportedSerializationFormats)Creates a newTHttpServicewith the specified service implementation, supporting the protocols specified inotherSupportedSerializationFormatsand defaulting to the specifieddefaultSerializationFormatwhen the client doesn't specify one.com.linecorp.armeria.common.HttpResponseserve(com.linecorp.armeria.server.ServiceRequestContext ctx, com.linecorp.armeria.common.HttpRequest req)Set<com.linecorp.armeria.common.SerializationFormat>supportedSerializationFormats()Returns theSerializationFormats supported by this service.Methods inherited from class com.linecorp.armeria.server.DecoratingService
serviceAdded, shouldCachePathMethods inherited from class com.linecorp.armeria.common.util.AbstractUnwrappable
as, delegate, toString
-
Method Details
-
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
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
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
-
ofFormats
public static THttpService ofFormats(Object implementation, com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat, com.linecorp.armeria.common.SerializationFormat... otherSupportedSerializationFormats)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 clientotherSupportedSerializationFormats- 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> otherSupportedSerializationFormats)Creates a newTHttpServicewith the specified service implementation, supporting the protocols specified inotherSupportedSerializationFormatsand 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 clientotherSupportedSerializationFormats- other serialization formats that should be supported by this service in addition to the default
-
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... otherSupportedSerializationFormats)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 clientotherSupportedSerializationFormats- 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> otherSupportedSerializationFormats)Creates a new decorator that supports the protocols specified inotherSupportedSerializationFormatsand 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 clientotherSupportedSerializationFormats- other serialization formats that should be supported by this service in addition to the default
-
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
-
supportedSerializationFormats
Returns theSerializationFormats supported by this service. -
defaultSerializationFormat
public com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat()Returns the defaultSerializationFormatof 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
-