Class THttpService
- All Implemented Interfaces:
Unwrappable
,HttpService
,Service<HttpRequest,HttpResponse>
public final class THttpService extends DecoratingService<RpcRequest,RpcResponse,HttpRequest,HttpResponse> implements HttpService
HttpService
that handles a Thrift call.- See Also:
ThriftProtocolFactories
-
Method Summary
Modifier and Type Method Description static THttpServiceBuilder
builder()
Creates a new instance ofTHttpServiceBuilder
which can build an instance ofTHttpService
fluently.SerializationFormat
defaultSerializationFormat()
Returns the defaultSerializationFormat
of this service.Map<String,ThriftServiceEntry>
entries()
Returns the information about the Thrift services being served.static Function<? super RpcService,THttpService>
newDecorator()
Creates a new decorator that supports all thrift protocols and defaults toTBinary
protocol when the client doesn't specify one.static Function<? super RpcService,THttpService>
newDecorator(SerializationFormat defaultSerializationFormat)
Creates a new decorator that supports all thrift protocols and defaults to the specifieddefaultSerializationFormat
when the client doesn't specify one.static Function<? super RpcService,THttpService>
newDecorator(SerializationFormat defaultSerializationFormat, SerializationFormat... otherSupportedSerializationFormats)
Creates a new decorator that supports only the formats specified and defaults to the specifieddefaultSerializationFormat
when the client doesn't specify one.static Function<? super RpcService,THttpService>
newDecorator(SerializationFormat defaultSerializationFormat, Iterable<SerializationFormat> otherSupportedSerializationFormats)
Creates a new decorator that supports the protocols specified inotherSupportedSerializationFormats
and defaults to the specifieddefaultSerializationFormat
when the client doesn't specify one.static THttpService
of(Object implementation)
Creates a newTHttpService
with the specified service implementation, supporting all thrift protocols and defaulting toTBinary
protocol when the client doesn't specify one.static THttpService
of(Object implementation, SerializationFormat defaultSerializationFormat)
Creates a newTHttpService
with the specified service implementation, supporting all thrift protocols and defaulting to the specifieddefaultSerializationFormat
when the client doesn't specify one.static THttpService
ofFormats(Object implementation, SerializationFormat defaultSerializationFormat, SerializationFormat... otherSupportedSerializationFormats)
Creates a newTHttpService
with the specified service implementation, supporting only the formats specified and defaulting to the specifieddefaultSerializationFormat
when the client doesn't specify one.static THttpService
ofFormats(Object implementation, SerializationFormat defaultSerializationFormat, Iterable<SerializationFormat> otherSupportedSerializationFormats)
Creates a newTHttpService
with the specified service implementation, supporting the protocols specified inotherSupportedSerializationFormats
and defaulting to the specifieddefaultSerializationFormat
when the client doesn't specify one.HttpResponse
serve(ServiceRequestContext ctx, HttpRequest req)
Serves an incomingRequest
.Set<SerializationFormat>
supportedSerializationFormats()
Returns theSerializationFormat
s supported by this service.Methods inherited from class com.linecorp.armeria.server.DecoratingService
serviceAdded, shouldCachePath
Methods inherited from class com.linecorp.armeria.common.util.AbstractUnwrappable
as, toString, unwrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.linecorp.armeria.server.Service
as, serviceAdded, shouldCachePath, unwrap
-
Method Details
-
builder
Creates a new instance ofTHttpServiceBuilder
which can build an instance ofTHttpService
fluently.The default SerializationFormat
ThriftSerializationFormats.BINARY
will 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 newTHttpService
with the specified service implementation, supporting all thrift protocols and defaulting toTBinary
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 appropriateSerializationFormat.mediaType()
.- Parameters:
implementation
- an implementation of*.Iface
or*.AsyncIface
service interface generated by the Apache Thrift compiler
-
of
public static THttpService of(Object implementation, SerializationFormat defaultSerializationFormat)Creates a newTHttpService
with the specified service implementation, supporting all thrift protocols and defaulting to the specifieddefaultSerializationFormat
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*.Iface
or*.AsyncIface
service 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, SerializationFormat defaultSerializationFormat, SerializationFormat... otherSupportedSerializationFormats)Creates a newTHttpService
with the specified service implementation, supporting only the formats specified and defaulting to the specifieddefaultSerializationFormat
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*.Iface
or*.AsyncIface
service 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, SerializationFormat defaultSerializationFormat, Iterable<SerializationFormat> otherSupportedSerializationFormats)Creates a newTHttpService
with the specified service implementation, supporting the protocols specified inotherSupportedSerializationFormats
and defaulting to the specifieddefaultSerializationFormat
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*.Iface
or*.AsyncIface
service 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 toTBinary
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 appropriateSerializationFormat.mediaType()
. -
newDecorator
public static Function<? super RpcService,THttpService> newDecorator(SerializationFormat defaultSerializationFormat)Creates a new decorator that supports all thrift protocols and defaults to the specifieddefaultSerializationFormat
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:
defaultSerializationFormat
- the default serialization format to use when not specified by the client
-
newDecorator
public static Function<? super RpcService,THttpService> newDecorator(SerializationFormat defaultSerializationFormat, SerializationFormat... otherSupportedSerializationFormats)Creates a new decorator that supports only the formats specified and defaults to the specifieddefaultSerializationFormat
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:
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 RpcService,THttpService> newDecorator(SerializationFormat defaultSerializationFormat, Iterable<SerializationFormat> otherSupportedSerializationFormats)Creates a new decorator that supports the protocols specified inotherSupportedSerializationFormats
and defaults to the specifieddefaultSerializationFormat
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:
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
Map
whose key is a service name, which could be an empty string if this service is not multiplexed
-
supportedSerializationFormats
Returns theSerializationFormat
s supported by this service. -
defaultSerializationFormat
Returns the defaultSerializationFormat
of this service. -
serve
Description copied from interface:Service
Serves an incomingRequest
.- Specified by:
serve
in interfaceHttpService
- Specified by:
serve
in interfaceService<HttpRequest,HttpResponse>
- Parameters:
ctx
- the context of the receivedRequest
req
- the receivedRequest
- Returns:
- the
Response
- Throws:
Exception
-