I - The type of objects received as content from a request to this server.O - The type of objects written as content from a response from this server.public abstract class HttpServer<I,O> extends java.lang.Object implements io.reactivex.netty.events.EventSource<HttpServerEventsListener>
| Constructor and Description |
|---|
HttpServer() |
| Modifier and Type | Method and Description |
|---|---|
abstract <II,OO> HttpServer<II,OO> |
addChannelHandlerAfter(io.netty.util.concurrent.EventExecutorGroup group,
java.lang.String baseName,
java.lang.String name,
rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
Adds a
ChannelHandler to ChannelPipeline for all connections created by this server. |
abstract <II,OO> HttpServer<II,OO> |
addChannelHandlerAfter(java.lang.String baseName,
java.lang.String name,
rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
Adds a
ChannelHandler to ChannelPipeline for all connections created by this server. |
abstract <II,OO> HttpServer<II,OO> |
addChannelHandlerBefore(io.netty.util.concurrent.EventExecutorGroup group,
java.lang.String baseName,
java.lang.String name,
rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
Adds a
ChannelHandler to ChannelPipeline for all connections created by this server. |
abstract <II,OO> HttpServer<II,OO> |
addChannelHandlerBefore(java.lang.String baseName,
java.lang.String name,
rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
Adds a
ChannelHandler to ChannelPipeline for all connections created by this server. |
abstract <II,OO> HttpServer<II,OO> |
addChannelHandlerFirst(io.netty.util.concurrent.EventExecutorGroup group,
java.lang.String name,
rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
Adds a
ChannelHandler to ChannelPipeline for all connections created by this server. |
abstract <II,OO> HttpServer<II,OO> |
addChannelHandlerFirst(java.lang.String name,
rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
Adds a
ChannelHandler to ChannelPipeline for all connections created by this
server. |
abstract <II,OO> HttpServer<II,OO> |
addChannelHandlerLast(io.netty.util.concurrent.EventExecutorGroup group,
java.lang.String name,
rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
Adds a
ChannelHandler to ChannelPipeline for all connections created by this server. |
abstract <II,OO> HttpServer<II,OO> |
addChannelHandlerLast(java.lang.String name,
rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
Adds a
ChannelHandler to ChannelPipeline for all connections created by this server. |
abstract void |
awaitShutdown()
Waits for the shutdown of this server.
|
abstract void |
awaitShutdown(long duration,
java.util.concurrent.TimeUnit timeUnit)
Waits for the shutdown of this server, waiting a maximum of the passed duration.
|
abstract <T> HttpServer<I,O> |
channelOption(io.netty.channel.ChannelOption<T> option,
T value)
Creates a new server instance, inheriting all configurations from this server and adding a
ChannelOption
for the server socket created by the newly created server instance. |
abstract <T> HttpServer<I,O> |
clientChannelOption(io.netty.channel.ChannelOption<T> option,
T value)
Creates a new server instance, inheriting all configurations from this server and adding a
ChannelOption
for the client socket created by the newly created server instance. |
abstract HttpServer<I,O> |
enableWireLogging(io.netty.handler.logging.LogLevel wireLoggingLevel)
Creates a new client instances, inheriting all configurations from this client and enabling wire logging at the
passed level for the newly created client instance.
|
abstract java.net.SocketAddress |
getServerAddress()
Returns the address at which this server is running.
|
abstract int |
getServerPort()
Returns the port at which this server is running.
|
static HttpServer<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> |
newServer()
Creates a new server using an ephemeral port.
|
static HttpServer<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> |
newServer(int port)
Creates a new server using the passed port.
|
static HttpServer<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> |
newServer(int port,
io.netty.channel.EventLoopGroup eventLoopGroup,
java.lang.Class<? extends io.netty.channel.ServerChannel> channelClass)
Creates a new server using the passed port.
|
static HttpServer<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> |
newServer(int port,
io.netty.channel.EventLoopGroup serverGroup,
io.netty.channel.EventLoopGroup clientGroup,
java.lang.Class<? extends io.netty.channel.ServerChannel> channelClass)
Creates a new server using the passed port.
|
static HttpServer<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> |
newServer(java.net.SocketAddress socketAddress)
Creates a new server using the passed port.
|
static HttpServer<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> |
newServer(java.net.SocketAddress socketAddress,
io.netty.channel.EventLoopGroup eventLoopGroup,
java.lang.Class<? extends io.netty.channel.ServerChannel> channelClass)
Creates a new server using the passed port.
|
static HttpServer<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> |
newServer(java.net.SocketAddress socketAddress,
io.netty.channel.EventLoopGroup serverGroup,
io.netty.channel.EventLoopGroup clientGroup,
java.lang.Class<? extends io.netty.channel.ServerChannel> channelClass)
Creates a new server using the passed port.
|
abstract <II,OO> HttpServer<II,OO> |
pipelineConfigurator(rx.functions.Action1<io.netty.channel.ChannelPipeline> pipelineConfigurator)
Creates a new client instances, inheriting all configurations from this client and using the passed action to
configure all the connections created by the newly created client instance.
|
abstract HttpServer<I,O> |
secure(rx.functions.Func1<io.netty.buffer.ByteBufAllocator,javax.net.ssl.SSLEngine> sslEngineFactory)
Creates a new server instances, inheriting all configurations from this server and using the passed
sslEngineFactory for all secured connections accepted by the newly created server instance. |
abstract HttpServer<I,O> |
secure(io.reactivex.netty.ssl.SslCodec sslCodec)
Creates a new server instances, inheriting all configurations from this server and using the passed
sslCodec for all secured connections accepted by the newly created server instance. |
abstract HttpServer<I,O> |
secure(javax.net.ssl.SSLEngine sslEngine)
Creates a new server instances, inheriting all configurations from this server and using the passed
sslEngine for all secured connections accepted by the newly created server instance. |
abstract HttpServer<I,O> |
sendHttp10ResponseFor10Request(boolean sendHttp10ResponseFor10Request)
According to the specification, an HTTP server must
send the highest HTTP version response, it is compatible with.
|
abstract void |
shutdown()
Shutdown this server and waits till the server socket is closed.
|
abstract HttpServer<I,O> |
start(RequestHandler<I,O> requestHandler)
Starts this server.
|
abstract HttpServer<I,O> |
unsafeSecure()
Creates a new server instances, inheriting all configurations from this server and using a self-signed
certificate for all secured connections accepted by the newly created server instance.
|
public abstract <T> HttpServer<I,O> channelOption(io.netty.channel.ChannelOption<T> option, T value)
ChannelOption
for the server socket created by the newly created server instance.option - Option to add.value - Value for the option.HttpServer instance.public abstract <T> HttpServer<I,O> clientChannelOption(io.netty.channel.ChannelOption<T> option, T value)
ChannelOption
for the client socket created by the newly created server instance.option - Option to add.value - Value for the option.HttpServer instance.public abstract <II,OO> HttpServer<II,OO> addChannelHandlerFirst(java.lang.String name, rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
ChannelHandler to ChannelPipeline for all connections created by this
server. The specified handler is added at the first position of the pipeline as specified by ChannelPipeline.addFirst(String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.name - Name of the handler.handlerFactory - Factory to create handler instance to add.HttpServer instance.public abstract <II,OO> HttpServer<II,OO> addChannelHandlerFirst(io.netty.util.concurrent.EventExecutorGroup group, java.lang.String name, rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
ChannelHandler to ChannelPipeline for all connections created by this server. The
specified handler is added at the first position of the pipeline as specified by ChannelPipeline.addFirst(EventExecutorGroup, String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.group - The EventExecutorGroup which will be used to execute the ChannelHandler methodsname - The name of the handler to appendhandlerFactory - Factory to create handler instance to add.HttpServer instance.public abstract <II,OO> HttpServer<II,OO> addChannelHandlerLast(java.lang.String name, rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
ChannelHandler to ChannelPipeline for all connections created by this server. The
specified handler is added at the last position of the pipeline as specified by
ChannelPipeline.addLast(String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.name - Name of the handler.handlerFactory - Factory to create handler instance to add.HttpServer instance.public abstract <II,OO> HttpServer<II,OO> addChannelHandlerLast(io.netty.util.concurrent.EventExecutorGroup group, java.lang.String name, rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
ChannelHandler to ChannelPipeline for all connections created by this server. The
specified handler is added at the last position of the pipeline as specified by ChannelPipeline.addLast(EventExecutorGroup, String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.group - the EventExecutorGroup which will be used to execute the ChannelHandler methodsname - the name of the handler to appendhandlerFactory - Factory to create handler instance to add.HttpServer instance.public abstract <II,OO> HttpServer<II,OO> addChannelHandlerBefore(java.lang.String baseName, java.lang.String name, rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
ChannelHandler to ChannelPipeline for all connections created by this server. The
specified handler is added before an existing handler with the passed baseName in the pipeline as
specified by ChannelPipeline.addBefore(String, String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.baseName - the name of the existing handlername - Name of the handler.handlerFactory - Factory to create handler instance to add.HttpServer instance.public abstract <II,OO> HttpServer<II,OO> addChannelHandlerBefore(io.netty.util.concurrent.EventExecutorGroup group, java.lang.String baseName, java.lang.String name, rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
ChannelHandler to ChannelPipeline for all connections created by this server. The
specified handler is added before an existing handler with the passed baseName in the pipeline as
specified by ChannelPipeline.addBefore(EventExecutorGroup, String, String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.group - the EventExecutorGroup which will be used to execute the ChannelHandler methodsbaseName - the name of the existing handlername - the name of the handler to appendhandlerFactory - Factory to create handler instance to add.HttpServer instance.public abstract <II,OO> HttpServer<II,OO> addChannelHandlerAfter(java.lang.String baseName, java.lang.String name, rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
ChannelHandler to ChannelPipeline for all connections created by this server. The
specified handler is added after an existing handler with the passed baseName in the pipeline as
specified by ChannelPipeline.addAfter(String, String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.baseName - the name of the existing handlername - Name of the handler.handlerFactory - Factory to create handler instance to add.HttpServer instance.public abstract <II,OO> HttpServer<II,OO> addChannelHandlerAfter(io.netty.util.concurrent.EventExecutorGroup group, java.lang.String baseName, java.lang.String name, rx.functions.Func0<io.netty.channel.ChannelHandler> handlerFactory)
ChannelHandler to ChannelPipeline for all connections created by this server. The
specified handler is added after an existing handler with the passed baseName in the pipeline as
specified by ChannelPipeline.addAfter(EventExecutorGroup, String, String, ChannelHandler)
For better flexibility of pipeline modification, the method pipelineConfigurator(Action1) will be
more convenient.group - the EventExecutorGroup which will be used to execute the ChannelHandler methodsbaseName - the name of the existing handlername - the name of the handler to appendhandlerFactory - Factory to create handler instance to add.HttpServer instance.public abstract <II,OO> HttpServer<II,OO> pipelineConfigurator(rx.functions.Action1<io.netty.channel.ChannelPipeline> pipelineConfigurator)
pipelineConfigurator - Action to configure ChannelPipeline.HttpServer instance.public abstract HttpServer<I,O> secure(rx.functions.Func1<io.netty.buffer.ByteBufAllocator,javax.net.ssl.SSLEngine> sslEngineFactory)
sslEngineFactory for all secured connections accepted by the newly created server instance.
If the SSLEngine instance can be statically, created, secure(SSLEngine) can be used.sslEngineFactory - Factory for all secured connections created by the newly created server instance.HttpServer instance.public abstract HttpServer<I,O> secure(javax.net.ssl.SSLEngine sslEngine)
sslEngine for all secured connections accepted by the newly created server instance.
If the SSLEngine instance can not be statically, created, secure(Func1) )} can be used.sslEngine - SSLEngine for all secured connections created by the newly created server instance.HttpServer instance.public abstract HttpServer<I,O> secure(io.reactivex.netty.ssl.SslCodec sslCodec)
sslCodec for all secured connections accepted by the newly created server instance.
This is required only when the SslHandler used by SslCodec is to be modified before adding to
the ChannelPipeline. For most of the cases, secure(Func1) or secure(SSLEngine) will be
enough.sslCodec - SslCodec for all secured connections created by the newly created server instance.HttpServer instance.public abstract HttpServer<I,O> unsafeSecure()
HttpServer instance.public abstract HttpServer<I,O> enableWireLogging(io.netty.handler.logging.LogLevel wireLoggingLevel)
wireLoggingLevel - Logging level at which the wire logs will be logged. The wire logging will only be done
if logging is enabled at this level for LoggingHandlerHttpServer instance.public abstract HttpServer<I,O> sendHttp10ResponseFor10Request(boolean sendHttp10ResponseFor10Request)
sendHttp10ResponseFor10Request - If true then sends 1.0 version response for 1.0 request.HttpServer instance.public abstract int getServerPort()
public abstract java.net.SocketAddress getServerAddress()
public abstract HttpServer<I,O> start(RequestHandler<I,O> requestHandler)
requestHandler - Connection handler that will handle any new client connections to this server.public abstract void shutdown()
public abstract void awaitShutdown()
public abstract void awaitShutdown(long duration,
java.util.concurrent.TimeUnit timeUnit)
duration - Duration to wait for shutdown.timeUnit - Timeunit for the duration to wait for shutdown.public static HttpServer<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> newServer()
getServerPort()HttpServerpublic static HttpServer<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> newServer(int port)
port - Port for the server. 0 to use ephemeral port.HttpServerpublic static HttpServer<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> newServer(int port, io.netty.channel.EventLoopGroup eventLoopGroup, java.lang.Class<? extends io.netty.channel.ServerChannel> channelClass)
port - Port for the server. 0 to use ephemeral port.eventLoopGroup - Eventloop group to be used for server as well as client sockets.channelClass - The class to be used for server channel.HttpServerpublic static HttpServer<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> newServer(int port, io.netty.channel.EventLoopGroup serverGroup, io.netty.channel.EventLoopGroup clientGroup, java.lang.Class<? extends io.netty.channel.ServerChannel> channelClass)
port - Port for the server. 0 to use ephemeral port.serverGroup - Eventloop group to be used for server sockets.clientGroup - Eventloop group to be used for client sockets.channelClass - The class to be used for server channel.HttpServerpublic static HttpServer<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> newServer(java.net.SocketAddress socketAddress)
socketAddress - Socket address for the server.HttpServerpublic static HttpServer<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> newServer(java.net.SocketAddress socketAddress, io.netty.channel.EventLoopGroup eventLoopGroup, java.lang.Class<? extends io.netty.channel.ServerChannel> channelClass)
socketAddress - Socket address for the server.eventLoopGroup - Eventloop group to be used for server as well as client sockets.channelClass - The class to be used for server channel.HttpServerpublic static HttpServer<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> newServer(java.net.SocketAddress socketAddress, io.netty.channel.EventLoopGroup serverGroup, io.netty.channel.EventLoopGroup clientGroup, java.lang.Class<? extends io.netty.channel.ServerChannel> channelClass)
socketAddress - Socket address for the server.serverGroup - Eventloop group to be used for server sockets.clientGroup - Eventloop group to be used for client sockets.channelClass - The class to be used for server channel.HttpServer