IN - The type that will be received by this serverOUT - The type that will be sent by this serverpublic abstract class HttpServer<IN,OUT> extends ReactorPeer<IN,OUT,HttpChannel<IN,OUT>>
| Modifier and Type | Field and Description |
|---|---|
protected reactor.bus.registry.Registry<HttpChannel,ReactorChannelHandler<IN,OUT,HttpChannel<IN,OUT>>> |
routedWriters |
started| Modifier | Constructor and Description |
|---|---|
protected |
HttpServer(reactor.Environment env,
reactor.core.Dispatcher dispatcher,
reactor.io.codec.Codec<reactor.io.buffer.Buffer,IN,OUT> codec) |
| Modifier and Type | Method and Description |
|---|---|
HttpServer<IN,OUT> |
delete(java.lang.String path,
ReactorChannelHandler<IN,OUT,HttpChannel<IN,OUT>> handler)
Listen for HTTP DELETE on the passed path to be used as a routing condition.
|
HttpServer<IN,OUT> |
get(java.lang.String path,
ReactorChannelHandler<IN,OUT,HttpChannel<IN,OUT>> handler)
Listen for HTTP GET on the passed path to be used as a routing condition.
|
abstract java.net.InetSocketAddress |
getListenAddress()
Get the address to which this server is bound.
|
protected boolean |
hasWebsocketEndpoints() |
protected abstract void |
onWebsocket(HttpChannel<IN,OUT> next) |
HttpServer<IN,OUT> |
post(java.lang.String path,
ReactorChannelHandler<IN,OUT,HttpChannel<IN,OUT>> handler)
Listen for HTTP POST on the passed path to be used as a routing condition.
|
HttpServer<IN,OUT> |
put(java.lang.String path,
ReactorChannelHandler<IN,OUT,HttpChannel<IN,OUT>> handler)
Listen for HTTP PUT on the passed path to be used as a routing condition.
|
HttpServer<IN,OUT> |
route(reactor.bus.selector.Selector<HttpChannel> condition,
ReactorChannelHandler<IN,OUT,HttpChannel<IN,OUT>> serviceFunction)
Register an handler for the given Selector condition, incoming connections will query the internal registry
to invoke the matching handlers.
|
protected java.lang.Iterable<? extends org.reactivestreams.Publisher<java.lang.Void>> |
routeChannel(HttpChannel<IN,OUT> ch) |
reactor.rx.Promise<java.lang.Void> |
start()
Start the server without any global handler, only the specific routed methods (get, post...) will apply.
|
HttpServer<IN,OUT> |
ws(java.lang.String path,
ReactorChannelHandler<IN,OUT,HttpChannel<IN,OUT>> handler)
Listen for WebSocket on the passed path to be used as a routing condition.
|
doShutdown, doStart, getDefaultCodec, getDefaultDispatcher, getDefaultEnvironment, getDefaultPrefetchSize, shutdown, startprotected final reactor.bus.registry.Registry<HttpChannel,ReactorChannelHandler<IN,OUT,HttpChannel<IN,OUT>>> routedWriters
public reactor.rx.Promise<java.lang.Void> start()
public abstract java.net.InetSocketAddress getListenAddress()
public HttpServer<IN,OUT> route(reactor.bus.selector.Selector<HttpChannel> condition, ReactorChannelHandler<IN,OUT,HttpChannel<IN,OUT>> serviceFunction)
condition - a Selector to match the incoming connection with registered handlerserviceFunction - an handler to invoke for the given conditionthispublic final HttpServer<IN,OUT> get(java.lang.String path, ReactorChannelHandler<IN,OUT,HttpChannel<IN,OUT>> handler)
HttpChannel.param(String)path - The HttpSelector to resolve against this path, pattern matching and capture are supportedhandler - an handler to invoke for the given conditionthispublic final HttpServer<IN,OUT> post(java.lang.String path, ReactorChannelHandler<IN,OUT,HttpChannel<IN,OUT>> handler)
HttpChannel.param(String)path - The HttpSelector to resolve against this path, pattern matching and capture are supportedhandler - an handler to invoke for the given conditionthispublic final HttpServer<IN,OUT> put(java.lang.String path, ReactorChannelHandler<IN,OUT,HttpChannel<IN,OUT>> handler)
HttpChannel.param(String)path - The HttpSelector to resolve against this path, pattern matching and capture are supportedhandler - an handler to invoke for the given conditionthispublic final HttpServer<IN,OUT> ws(java.lang.String path, ReactorChannelHandler<IN,OUT,HttpChannel<IN,OUT>> handler)
HttpChannel.param(String)path - The HttpSelector to resolve against this path, pattern matching and capture are supportedhandler - an handler to invoke for the given conditionthispublic final HttpServer<IN,OUT> delete(java.lang.String path, ReactorChannelHandler<IN,OUT,HttpChannel<IN,OUT>> handler)
HttpChannel.param(String)path - The HttpSelector to resolve against this path, pattern matching and capture are supportedhandler - an handler to invoke for the given conditionthisprotected abstract void onWebsocket(HttpChannel<IN,OUT> next)
protected final boolean hasWebsocketEndpoints()
protected java.lang.Iterable<? extends org.reactivestreams.Publisher<java.lang.Void>> routeChannel(HttpChannel<IN,OUT> ch)