public class DelegatingHttpServerBuilder extends Object implements HttpServerBuilder
HttpServerBuilder that delegates all methods to another HttpServerBuilder.| Constructor and Description |
|---|
DelegatingHttpServerBuilder(HttpServerBuilder delegate)
Create a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
HttpServerBuilder |
allowDropRequestTrailers(boolean allowDrop)
Provide a hint if request trailers are allowed to
be dropped.
|
HttpServerBuilder |
appendConnectionAcceptorFilter(ConnectionAcceptorFactory factory)
Appends the filter to the chain of filters used to decorate the
ConnectionAcceptor used by this builder. |
HttpServerBuilder |
appendNonOffloadingServiceFilter(Predicate<StreamingHttpRequest> predicate,
StreamingHttpServiceFilterFactory factory)
Appends a non-offloading filter to the chain of filters used to decorate the
StreamingHttpService used
by this builder, for every request that passes the provided Predicate. |
HttpServerBuilder |
appendNonOffloadingServiceFilter(StreamingHttpServiceFilterFactory factory)
Appends a non-offloading filter to the chain of filters used to decorate the
StreamingHttpService used
by this builder. |
HttpServerBuilder |
appendServiceFilter(Predicate<StreamingHttpRequest> predicate,
StreamingHttpServiceFilterFactory factory)
Appends the filter to the chain of filters used to decorate the
StreamingHttpService used by this
builder, for every request that passes the provided Predicate. |
HttpServerBuilder |
appendServiceFilter(StreamingHttpServiceFilterFactory factory)
Appends the filter to the chain of filters used to decorate the
StreamingHttpService used by this
builder. |
HttpServerBuilder |
bufferAllocator(BufferAllocator allocator)
Sets the
BufferAllocator to be used by this server. |
protected HttpServerBuilder |
delegate()
Returns the
HttpServerBuilder delegate. |
HttpServerBuilder |
drainRequestPayloadBody(boolean enable)
Configure automatic consumption of request
payload body when it is not
consumed by the service. |
HttpServerBuilder |
enableWireLogging(String loggerName,
LogLevel logLevel,
BooleanSupplier logUserData)
Enables wire-logging for this server.
|
HttpServerBuilder |
executionStrategy(HttpExecutionStrategy strategy)
Sets the
HttpExecutionStrategy to be used by this server. |
HttpServerBuilder |
executor(Executor executor)
Sets the
Executor to be used by this server. |
HttpServerBuilder |
ioExecutor(IoExecutor ioExecutor)
Sets the
IoExecutor to be used by this server. |
HttpServerBuilder |
lifecycleObserver(HttpLifecycleObserver lifecycleObserver)
Sets a
HttpLifecycleObserver that provides visibility into HTTP lifecycle events. |
Single<HttpServerContext> |
listen(HttpService service)
Starts this server and returns the
HttpServerContext after the server has been successfully started. |
HttpServerContext |
listenAndAwait(HttpService service)
Starts this server and returns the
HttpServerContext after the server has been successfully started. |
Single<HttpServerContext> |
listenBlocking(BlockingHttpService service)
Starts this server and returns the
HttpServerContext after the server has been successfully started. |
HttpServerContext |
listenBlockingAndAwait(BlockingHttpService service)
Starts this server and returns the
HttpServerContext after the server has been successfully started. |
Single<HttpServerContext> |
listenBlockingStreaming(BlockingStreamingHttpService service)
Starts this server and returns the
HttpServerContext after the server has been successfully started. |
HttpServerContext |
listenBlockingStreamingAndAwait(BlockingStreamingHttpService service)
Starts this server and returns the
HttpServerContext after the server has been successfully started. |
<T> HttpServerBuilder |
listenSocketOption(SocketOption<T> option,
T value)
Adds a
SocketOption that is applied to the server socket channel which listens/accepts socket channels. |
Single<HttpServerContext> |
listenStreaming(StreamingHttpService service)
Starts this server and returns the
HttpServerContext after the server has been successfully started. |
HttpServerContext |
listenStreamingAndAwait(StreamingHttpService service)
Starts this server and returns the
HttpServerContext after the server has been successfully started. |
HttpServerBuilder |
protocols(HttpProtocolConfig... protocols)
Configurations of various HTTP protocol versions.
|
<T> HttpServerBuilder |
socketOption(SocketOption<T> option,
T value)
Adds a
SocketOption that is applied to connected/accepted socket channels. |
HttpServerBuilder |
sslConfig(ServerSslConfig config)
Set the SSL/TLS configuration.
|
HttpServerBuilder |
sslConfig(ServerSslConfig defaultConfig,
Map<String,ServerSslConfig> sniMap)
Set the SSL/TLS and SNI configuration.
|
String |
toString() |
HttpServerBuilder |
transportObserver(TransportObserver transportObserver)
Sets a
TransportObserver that provides visibility into transport events. |
public DelegatingHttpServerBuilder(HttpServerBuilder delegate)
delegate - HttpServerBuilder to which all methods are delegated.protected final HttpServerBuilder delegate()
HttpServerBuilder delegate.HttpServerBuilder.public String toString()
toString in class Objectpublic HttpServerBuilder protocols(HttpProtocolConfig... protocols)
HttpServerBuilder
Note: the order of specified protocols will reflect on priorities for
ALPN in case the connections use
HttpServerBuilder.sslConfig(ServerSslConfig).
protocols in interface HttpServerBuilderprotocols - HttpProtocolConfig for each protocol that should be supported.this.public HttpServerBuilder sslConfig(ServerSslConfig config)
HttpServerBuildersslConfig in interface HttpServerBuilderconfig - The configuration to use.this.public HttpServerBuilder sslConfig(ServerSslConfig defaultConfig, Map<String,ServerSslConfig> sniMap)
HttpServerBuildersslConfig in interface HttpServerBuilderdefaultConfig - The configuration to use is the client certificate's SNI extension isn't present or the
SNI hostname doesn't match any values in sniMap.sniMap - A map where the keys are matched against the client certificate's SNI extension value in order
to provide the corresponding ServerSslConfig.this.public <T> HttpServerBuilder socketOption(SocketOption<T> option, T value)
HttpServerBuilderSocketOption that is applied to connected/accepted socket channels.socketOption in interface HttpServerBuilderT - the type of the value.option - the option to apply.value - the value.StandardSocketOptions,
ServiceTalkSocketOptionspublic <T> HttpServerBuilder listenSocketOption(SocketOption<T> option, T value)
HttpServerBuilderSocketOption that is applied to the server socket channel which listens/accepts socket channels.listenSocketOption in interface HttpServerBuilderT - the type of the value.option - the option to apply.value - the value.StandardSocketOptions,
ServiceTalkSocketOptionspublic HttpServerBuilder enableWireLogging(String loggerName, LogLevel logLevel, BooleanSupplier logUserData)
HttpServerBuilderenableWireLogging in interface HttpServerBuilderloggerName - The name of the logger to log wire events.logLevel - The level to log at.logUserData - true to include user data (e.g. data, headers, etc.). false to exclude user
data and log only network events. This method is invoked for each data object allowing for dynamic behavior.this.public HttpServerBuilder transportObserver(TransportObserver transportObserver)
HttpServerBuilderTransportObserver that provides visibility into transport events.transportObserver in interface HttpServerBuildertransportObserver - A TransportObserver that provides visibility into transport events.this.public HttpServerBuilder lifecycleObserver(HttpLifecycleObserver lifecycleObserver)
HttpServerBuilderHttpLifecycleObserver that provides visibility into HTTP lifecycle events.
This method allows setting a HttpLifecycleObserver in a position that captures entire state of the
execution chain, including all filters and internal post-processing. If it's necessary to observe an exchange
after other filters or apply it conditionally, consider using
io.servicetalk.http.netty.HttpLifecycleObserverServiceFilter instead.
lifecycleObserver in interface HttpServerBuilderlifecycleObserver - A HttpLifecycleObserver that provides visibility into HTTP lifecycle events.this.public HttpServerBuilder drainRequestPayloadBody(boolean enable)
HttpServerBuilderpayload body when it is not
consumed by the service.
For persistent HTTP connections it is required to
eventually consume the entire request payload to enable reading of the next request. This is required because
requests are pipelined for HTTP/1.1, so if the previous request is not completely read, next request can not be
read from the socket. For cases when there is a possibility that user may forget to consume request payload,
ServiceTalk automatically consumes request payload body. This automatic consumption behavior may create some
overhead and can be disabled using this method when it is guaranteed that all request paths consumes all request
payloads eventually. An example of guaranteed consumption are non-streaming APIs.
drainRequestPayloadBody in interface HttpServerBuilderenable - When false it will disable the automatic consumption of request
StreamingHttpRequest.payloadBody().this.public HttpServerBuilder allowDropRequestTrailers(boolean allowDrop)
HttpServerBuilderallowDropRequestTrailers in interface HttpServerBuilderallowDrop - true if request trailers
are allowed to be dropped.thispublic HttpServerBuilder appendConnectionAcceptorFilter(ConnectionAcceptorFactory factory)
HttpServerBuilderConnectionAcceptor used by this builder.
The order of execution of these filters are in order of append. If 3 filters are added as follows:
builder
.appendConnectionAcceptorFilter(filter1)
.appendConnectionAcceptorFilter(filter2)
.appendConnectionAcceptorFilter(filter3)
accepting a connection by a filter wrapped by this filter chain, the order of invocation of these filters will
be:
filter1 ⇒ filter2 ⇒ filter3
The connection acceptor will, by default, not be offloaded. If your filter requires the
ConnectionAcceptor.accept(ConnectionContext) to be offloaded then your
ConnectionAcceptorFactory will need to return ConnectExecutionStrategy.offloadAll() from the
ExecutionStrategyInfluencer.requiredOffloads().
appendConnectionAcceptorFilter in interface HttpServerBuilderfactory - ConnectionAcceptorFactory to append. Lifetime of this
ConnectionAcceptorFactory is managed by this builder and the server started thereof.thispublic HttpServerBuilder appendNonOffloadingServiceFilter(StreamingHttpServiceFilterFactory factory)
HttpServerBuilderStreamingHttpService used
by this builder.
Note this method will be used to decorate the StreamingHttpService passed to
HttpServerBuilder.listenStreaming(StreamingHttpService) before it is used by the server.
The order of execution of these filters are in order of append, before the filters added with
HttpServerBuilder.appendServiceFilter(StreamingHttpServiceFilterFactory). If 3 filters are added as follows:
builder
.appendServiceFilter(filter1)
.appendNonOffloadingServiceFilter(filter2)
.appendServiceFilter(filter3)
accepting a request by a service wrapped by this filter chain, the order of invocation of these filters will be:
filter2 ⇒ [offloading] ⇒ filter1 ⇒ filter3 ⇒ service
appendNonOffloadingServiceFilter in interface HttpServerBuilderfactory - StreamingHttpServiceFilterFactory to append.thispublic HttpServerBuilder appendNonOffloadingServiceFilter(Predicate<StreamingHttpRequest> predicate, StreamingHttpServiceFilterFactory factory)
HttpServerBuilderStreamingHttpService used
by this builder, for every request that passes the provided Predicate. Filters added via this method
will be executed before offloading occurs and before filters appended via
HttpServerBuilder.appendServiceFilter(StreamingHttpServiceFilterFactory).
Note this method will be used to decorate the StreamingHttpService passed to
HttpServerBuilder.listenStreaming(StreamingHttpService) before it is used by the server.
The order of execution of these filters are in order of append, before the filters added with
HttpServerBuilder.appendServiceFilter(StreamingHttpServiceFilterFactory). If 3 filters are added as follows:
builder
.appendServiceFilter(filter1)
.appendNonOffloadingServiceFilter(filter2)
.appendServiceFilter(filter3)
accepting a request by a service wrapped by this filter chain, the order of invocation of these filters will be:
filter2 ⇒ [offloading] ⇒ filter1 ⇒ filter3 ⇒ service
appendNonOffloadingServiceFilter in interface HttpServerBuilderpredicate - the Predicate to test if the filter must be applied. This must not block.factory - StreamingHttpServiceFilterFactory to append.thispublic HttpServerBuilder appendServiceFilter(StreamingHttpServiceFilterFactory factory)
HttpServerBuilderStreamingHttpService used by this
builder.
Note this method will be used to decorate the StreamingHttpService passed to
HttpServerBuilder.listenStreaming(StreamingHttpService) before it is used by the server.
The order of execution of these filters are in order of append. If 3 filters are added as follows:
builder.appendServiceFilter(filter1).appendServiceFilter(filter2).appendServiceFilter(filter3)
accepting a request by a service wrapped by this filter chain, the order of invocation of these filters will be:
filter1 ⇒ filter2 ⇒ filter3 ⇒ service
appendServiceFilter in interface HttpServerBuilderfactory - StreamingHttpServiceFilterFactory to append.thispublic HttpServerBuilder appendServiceFilter(Predicate<StreamingHttpRequest> predicate, StreamingHttpServiceFilterFactory factory)
HttpServerBuilderStreamingHttpService used by this
builder, for every request that passes the provided Predicate.
Note this method will be used to decorate the StreamingHttpService passed to
HttpServerBuilder.listenStreaming(StreamingHttpService) before it is used by the server.
The order of execution of these filters are in order of append. If 3 filters are added as follows:
builder.appendServiceFilter(filter1).appendServiceFilter(filter2).appendServiceFilter(filter3)
accepting a request by a service wrapped by this filter chain, the order of invocation of these filters will be:
filter1 ⇒ filter2 ⇒ filter3 ⇒ service
appendServiceFilter in interface HttpServerBuilderpredicate - the Predicate to test if the filter must be applied. This must not block.factory - StreamingHttpServiceFilterFactory to append.thispublic HttpServerBuilder ioExecutor(IoExecutor ioExecutor)
HttpServerBuilderIoExecutor to be used by this server.ioExecutor in interface HttpServerBuilderioExecutor - IoExecutor to use.this.public HttpServerBuilder executor(Executor executor)
HttpServerBuilderExecutor to be used by this server.executor in interface HttpServerBuilderexecutor - Executor to use.this.public HttpServerBuilder bufferAllocator(BufferAllocator allocator)
HttpServerBuilderBufferAllocator to be used by this server.bufferAllocator in interface HttpServerBuilderallocator - BufferAllocator to use.this.public HttpServerBuilder executionStrategy(HttpExecutionStrategy strategy)
HttpServerBuilderHttpExecutionStrategy to be used by this server.executionStrategy in interface HttpServerBuilderstrategy - HttpExecutionStrategy to use by this server.this.public Single<HttpServerContext> listen(HttpService service)
HttpServerBuilderHttpServerContext after the server has been successfully started.
If the underlying protocol (e.g. TCP) supports it this will result in a socket bind/listen on address.
listen in interface HttpServerBuilderservice - Service invoked for every request received by this server. The returned HttpServerContext
manages the lifecycle of the service, ensuring it is closed when the HttpServerContext is closed.Single that completes when the server is successfully started or terminates with an error if
the server could not be started.public Single<HttpServerContext> listenStreaming(StreamingHttpService service)
HttpServerBuilderHttpServerContext after the server has been successfully started.
If the underlying protocol (e.g. TCP) supports it this will result in a socket bind/listen on address.
listenStreaming in interface HttpServerBuilderservice - Service invoked for every request received by this server. The returned HttpServerContext
manages the lifecycle of the service, ensuring it is closed when the HttpServerContext is closed.Single that completes when the server is successfully started or terminates with an error if
the server could not be started.public Single<HttpServerContext> listenBlocking(BlockingHttpService service)
HttpServerBuilderHttpServerContext after the server has been successfully started.
If the underlying protocol (e.g. TCP) supports it this will result in a socket bind/listen on address.
listenBlocking in interface HttpServerBuilderservice - Service invoked for every request received by this server. The returned HttpServerContext
manages the lifecycle of the service, ensuring it is closed when the HttpServerContext is closed.Single that completes when the server is successfully started or terminates with an error if
the server could not be started.public Single<HttpServerContext> listenBlockingStreaming(BlockingStreamingHttpService service)
HttpServerBuilderHttpServerContext after the server has been successfully started.
If the underlying protocol (e.g. TCP) supports it this will result in a socket bind/listen on address.
listenBlockingStreaming in interface HttpServerBuilderservice - Service invoked for every request received by this server. The returned HttpServerContext
manages the lifecycle of the service, ensuring it is closed when the HttpServerContext is closed.Single that completes when the server is successfully started or terminates with an error if
the server could not be started.public HttpServerContext listenAndAwait(HttpService service) throws Exception
HttpServerBuilderHttpServerContext after the server has been successfully started.
If the underlying protocol (e.g. TCP) supports it this will result in a socket bind/listen on address.
listenAndAwait in interface HttpServerBuilderservice - Service invoked for every request received by this server. The returned HttpServerContext
manages the lifecycle of the service, ensuring it is closed when the HttpServerContext is closed.HttpServerContext by blocking the calling thread until the server is successfully started or
throws an Exception if the server could not be started.Exception - if the server could not be started.public HttpServerContext listenStreamingAndAwait(StreamingHttpService service) throws Exception
HttpServerBuilderHttpServerContext after the server has been successfully started.
If the underlying protocol (e.g. TCP) supports it this will result in a socket bind/listen on address.
listenStreamingAndAwait in interface HttpServerBuilderservice - Service invoked for every request received by this server. The returned HttpServerContext
manages the lifecycle of the service, ensuring it is closed when the HttpServerContext is closed.HttpServerContext by blocking the calling thread until the server is successfully started or
throws an Exception if the server could not be started.Exception - if the server could not be started.public HttpServerContext listenBlockingAndAwait(BlockingHttpService service) throws Exception
HttpServerBuilderHttpServerContext after the server has been successfully started.
If the underlying protocol (e.g. TCP) supports it this will result in a socket bind/listen on address.
listenBlockingAndAwait in interface HttpServerBuilderservice - Service invoked for every request received by this server. The returned HttpServerContext
manages the lifecycle of the service, ensuring it is closed when the HttpServerContext is closed.HttpServerContext by blocking the calling thread until the server is successfully started or
throws an Exception if the server could not be started.Exception - if the server could not be started.public HttpServerContext listenBlockingStreamingAndAwait(BlockingStreamingHttpService service) throws Exception
HttpServerBuilderHttpServerContext after the server has been successfully started.
If the underlying protocol (e.g. TCP) supports it this will result in a socket bind/listen on address.
listenBlockingStreamingAndAwait in interface HttpServerBuilderservice - Service invoked for every request received by this server. The returned HttpServerContext
manages the lifecycle of the service, ensuring it is closed when the HttpServerContext is closed.HttpServerContext by blocking the calling thread until the server is successfully started or
throws an Exception if the server could not be started.Exception - if the server could not be started.