Class THttpService
- All Implemented Interfaces:
Unwrappable
,HttpService
,Service<HttpRequest,
HttpResponse>
HttpService
that handles a Thrift call.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic THttpServiceBuilder
builder()
Creates a new instance ofTHttpServiceBuilder
which can build an instance ofTHttpService
fluently.Returns the defaultSerializationFormat
of this service.entries()
Returns the information about the Thrift services being served.exchangeType
(RoutingContext routingContext) static Function<? super RpcService,
THttpService> 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
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.serve
(ServiceRequestContext ctx, HttpRequest req) Serves an incomingRequest
.void
Invoked when this service has been added to aServer
with the specified configuration.Returns theSerializationFormat
s supported by this service.Methods inherited from class com.linecorp.armeria.server.DecoratingService
shouldCachePath
Methods inherited from class com.linecorp.armeria.common.util.AbstractUnwrappable
as, toString, unwrap, unwrapAll
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.HttpService
decorate, decorate
Methods inherited from interface com.linecorp.armeria.server.Service
as, shouldCachePath, unwrap
Methods inherited from interface com.linecorp.armeria.common.util.Unwrappable
equalsIgnoreWrapper, unwrapAll
-
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. -
serviceAdded
Description copied from interface:Service
Invoked when this service has been added to aServer
with the specified configuration. Please note that this method can be invoked more than once if this service has been added more than once.- Specified by:
serviceAdded
in interfaceService<HttpRequest,
HttpResponse> - Overrides:
serviceAdded
in classDecoratingService<RpcRequest,
RpcResponse, HttpRequest, HttpResponse> - Throws:
Exception
-
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
-
exchangeType
Description copied from interface:HttpService
Determines anExchangeType
for thisHttpService
from the givenRoutingContext
. By default,ExchangeType.BIDI_STREAMING
is set.Note that an
HttpRequest
will be aggregated before serving theHttpService
ifExchangeType.UNARY
orExchangeType.RESPONSE_STREAMING
is set.- Specified by:
exchangeType
in interfaceHttpService
-