public interface ServerBuilder
Use Http.newServerAt()
to create a builder, use methods to customize settings,
and then call one of the bind* methods to bind a server.
Modifier and Type | Method and Description |
---|---|
ServerBuilder |
adaptSettings(org.apache.pekko.japi.function.Function<ServerSettings,ServerSettings> f)
Adapt the current configured settings with a function.
|
java.util.concurrent.CompletionStage<ServerBinding> |
bind(org.apache.pekko.japi.function.Function<HttpRequest,java.util.concurrent.CompletionStage<HttpResponse>> f)
Bind a new HTTP server and use the given asynchronous
handler
pekko.stream.javadsl.Flow for processing all incoming connections. |
java.util.concurrent.CompletionStage<ServerBinding> |
bind(HandlerProvider handlerProvider)
Bind a new HTTP server and use the given handler provider to create an asynchronous
handler
pekko.stream.javadsl.Flow for processing all incoming connections. |
java.util.concurrent.CompletionStage<ServerBinding> |
bindFlow(org.apache.pekko.stream.javadsl.Flow<HttpRequest,HttpResponse,?> handlerFlow)
Binds a new HTTP server at the given endpoint and uses the given
handler
pekko.stream.scaladsl.Flow for processing all incoming connections. |
java.util.concurrent.CompletionStage<ServerBinding> |
bindSync(org.apache.pekko.japi.function.Function<HttpRequest,HttpResponse> f)
Bind a new HTTP server at the given endpoint and uses the given
handler
pekko.stream.javadsl.Flow for processing all incoming connections. |
org.apache.pekko.stream.javadsl.Source<IncomingConnection,java.util.concurrent.CompletionStage<ServerBinding>> |
connectionSource()
Creates a
pekko.stream.javadsl.Source of pekko.http.javadsl.IncomingConnection instances which represents a prospective HTTP server binding
on the given endpoint . |
ServerBuilder |
enableHttps(HttpsConnectionContext context)
Enable HTTPS for this binding with the given context.
|
ServerBuilder |
logTo(org.apache.pekko.event.LoggingAdapter log)
Use a custom logger
|
ServerBuilder |
onInterface(java.lang.String interface_)
Change interface to bind to
|
ServerBuilder |
onPort(int port)
Change port to bind to
|
ServerBuilder |
withMaterializer(org.apache.pekko.stream.Materializer materializer)
Use custom
Materializer for the binding |
ServerBuilder |
withSettings(ServerSettings settings)
Use custom
ServerSettings for the binding. |
ServerBuilder onInterface(java.lang.String interface_)
ServerBuilder onPort(int port)
ServerBuilder logTo(org.apache.pekko.event.LoggingAdapter log)
ServerBuilder withSettings(ServerSettings settings)
ServerSettings
for the binding.settings
- (undocumented)ServerBuilder adaptSettings(org.apache.pekko.japi.function.Function<ServerSettings,ServerSettings> f)
f
- (undocumented)ServerBuilder enableHttps(HttpsConnectionContext context)
context
- (undocumented)ServerBuilder withMaterializer(org.apache.pekko.stream.Materializer materializer)
Materializer
for the bindingmaterializer
- (undocumented)java.util.concurrent.CompletionStage<ServerBinding> bind(org.apache.pekko.japi.function.Function<HttpRequest,java.util.concurrent.CompletionStage<HttpResponse>> f)
handler
pekko.stream.javadsl.Flow
for processing all incoming connections.
The number of concurrently accepted connections can be configured by overriding
the pekko.http.server.max-connections
setting. Please see the documentation in the reference.conf for more
information about what kind of guarantees to expect.
Supports HTTP/2 on the same port if http2 support is enabled.
f
- (undocumented)java.util.concurrent.CompletionStage<ServerBinding> bind(HandlerProvider handlerProvider)
handler
pekko.stream.javadsl.Flow
for processing all incoming connections.
Most importantly, you can pass a Route to this method because Route implements HandlerProvider.
The number of concurrently accepted connections can be configured by overriding
the pekko.http.server.max-connections
setting. Please see the documentation in the reference.conf for more
information about what kind of guarantees to expect.
Supports HTTP/2 on the same port if http2 support is enabled.
handlerProvider
- (undocumented)java.util.concurrent.CompletionStage<ServerBinding> bindSync(org.apache.pekko.japi.function.Function<HttpRequest,HttpResponse> f)
handler
pekko.stream.javadsl.Flow
for processing all incoming connections.
The number of concurrently accepted connections can be configured by overriding
the pekko.http.server.max-connections
setting. Please see the documentation in the reference.conf for more
information about what kind of guarantees to expect.
Supports HTTP/2 on the same port if http2 support is enabled.
f
- (undocumented)java.util.concurrent.CompletionStage<ServerBinding> bindFlow(org.apache.pekko.stream.javadsl.Flow<HttpRequest,HttpResponse,?> handlerFlow)
handler
pekko.stream.scaladsl.Flow
for processing all incoming connections.
The number of concurrently accepted connections can be configured by overriding
the pekko.http.server.max-connections
setting. Please see the documentation in the reference.conf for more
information about what kind of guarantees to expect.
handlerFlow
- (undocumented)org.apache.pekko.stream.javadsl.Source<IncomingConnection,java.util.concurrent.CompletionStage<ServerBinding>> connectionSource()
pekko.stream.javadsl.Source
of pekko.http.javadsl.IncomingConnection
instances which represents a prospective HTTP server binding
on the given endpoint
.
Note that each materialization will create a new binding, so
* if the configured port is 0 the resulting source can be materialized several times. Each materialization will
then be assigned a new local port by the operating system, which can then be retrieved by the materialized
pekko.http.javadsl.ServerBinding
.
* if the configured port is non-zero subsequent materialization attempts of the produced source will immediately
fail, unless the first materialization has already been unbound. Unbinding can be triggered via the materialized
pekko.http.javadsl.ServerBinding
.