Class THttpServiceBuilder
public final class THttpServiceBuilder extends Object
THttpService. This builder allows to bind multiple thrift
service implementations along with mixing TMultiplexed protocol to a route.
Example
Server server =
Server.builder()
.http(8080)
.service("/", THttpService.builder()
.addService(new FooService()) // foo() method
.addService(new BarService()) // bar() method
.addService("foobar", new FooBarService()) // TMultiplexed service
.build())
.build();
When the thrift request has a method foo() then FooService.foo() handles the request and
similarly when thrift request has a method bar() then BarService.bar() handles the request.
And when the service name is "foobar" then FooBarService
- See Also:
THttpService,ThriftCallService
-
Method Summary
Modifier and Type Method Description THttpServiceBuilderaddService(Object implementation)Adds a new service implementation to the builder.THttpServiceBuilderaddService(String name, Object implementation)Adds a newTMultiplexedservice to the builder.THttpServicebuild()Builds a new instance ofTHttpService.THttpServiceBuilderdecorate(Function<? super com.linecorp.armeria.server.RpcService,? extends com.linecorp.armeria.server.RpcService> decoratorFunction)AFunction<? super RpcService, ? extends RpcService>to decorate theRpcService.THttpServiceBuilderdefaultSerializationFormat(com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat)Adds the default serialization format which will be used when the client does not specify one in request.THttpServiceBuilderotherSerializationFormats(com.linecorp.armeria.common.SerializationFormat otherSerializationFormat)Adds otherSerializationFormatto the builder.THttpServiceBuilderotherSerializationFormats(Iterable<com.linecorp.armeria.common.SerializationFormat> otherSerializationFormats)Adds otherSerializationFormatto the builder.
-
Method Details
-
addService
Adds a newTMultiplexedservice to the builder.- Parameters:
name- name of the service.implementation- an implementation of*.Ifaceor*.AsyncIfaceservice interface generated by the Apache Thrift compiler.
-
addService
Adds a new service implementation to the builder.- Parameters:
implementation- an implementation of*.Ifaceor*.AsyncIfaceservice interface generated by the Apache Thrift compiler
-
otherSerializationFormats
public THttpServiceBuilder otherSerializationFormats(com.linecorp.armeria.common.SerializationFormat otherSerializationFormat)Adds otherSerializationFormatto the builder. Current supportedSerializationFormats areThriftSerializationFormats.values(). If nothing is specified then all theSerializationFormat.values()s are added.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(). -
otherSerializationFormats
public THttpServiceBuilder otherSerializationFormats(Iterable<com.linecorp.armeria.common.SerializationFormat> otherSerializationFormats)Adds otherSerializationFormatto the builder. Current supportedSerializationFormats areThriftSerializationFormats.values(). If nothing is specified then all theSerializationFormat.values()s are added.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(). -
defaultSerializationFormat
public THttpServiceBuilder defaultSerializationFormat(com.linecorp.armeria.common.SerializationFormat defaultSerializationFormat)Adds the default serialization format which will be used when the client does not specify one in request.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(). -
decorate
public THttpServiceBuilder decorate(Function<? super com.linecorp.armeria.server.RpcService,? extends com.linecorp.armeria.server.RpcService> decoratorFunction)AFunction<? super RpcService, ? extends RpcService>to decorate theRpcService. -
build
Builds a new instance ofTHttpService.
-