public interface HttpServerRoutes extends java.util.function.BiFunction<HttpServerRequest,HttpServerResponse,Publisher<Void>>
Modifier and Type | Field and Description |
---|---|
static java.util.function.Predicate<HttpServerRequest> |
INDEX_PREDICATE |
Modifier and Type | Method and Description |
---|---|
HttpServerRoutes |
comparator(Comparator<HttpRouteHandlerMetadata> comparator)
Use the provided
Comparator to sort routes, rather than using configured order.Routes that were
already configured are also impacted by this change and will be sorted according to the comparator.You can revert
to using the declaration order by calling the noComparator() method (which is the default). |
default HttpServerRoutes |
delete(String path,
java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
Listens for HTTP DELETE on the passed path to be used as a routing condition.
|
default HttpServerRoutes |
directory(String uri,
Path directory)
Listens for HTTP GET on the passed path to be used as a routing condition.
|
HttpServerRoutes |
directory(String uri,
Path directory,
java.util.function.Function<HttpServerResponse,HttpServerResponse> interceptor)
Listens for HTTP GET on the passed path to be used as a routing condition.The
content of the provided
directory will be served. |
default HttpServerRoutes |
file(java.util.function.Predicate<HttpServerRequest> uri,
Path path,
java.util.function.Function<HttpServerResponse,HttpServerResponse> interceptor)
Listens for HTTP GET on the passed path to be used as a routing condition.
|
default HttpServerRoutes |
file(String uri,
Path path)
Listens for HTTP GET on the passed path to be used as a routing condition.
|
default HttpServerRoutes |
file(String uri,
String path)
Listens for HTTP GET on the passed path to be used as a routing condition.
|
default HttpServerRoutes |
get(String path,
java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
Listens for HTTP GET on the passed path to be used as a routing condition.
|
default HttpServerRoutes |
head(String path,
java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
Listens for HTTP HEAD on the passed path to be used as a routing condition.
|
default HttpServerRoutes |
index(java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
This route will be invoked when GET "/path" or "/path/" like uri are requested.
|
static HttpServerRoutes |
newRoutes()
Returns a new default routing registry
HttpServerRoutes |
HttpServerRoutes |
noComparator()
Removes any previously applied
Comparator customization using
comparator(Comparator) , and use the order in which the routes were configured. |
default HttpServerRoutes |
options(String path,
java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
Listens for HTTP OPTIONS on the passed path to be used as a routing condition.
|
default HttpServerRoutes |
post(String path,
java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
Listens for HTTP POST on the passed path to be used as a routing condition.
|
default HttpServerRoutes |
put(String path,
java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
Listens for HTTP PUT on the passed path to be used as a routing condition.
|
HttpServerRoutes |
route(java.util.function.Predicate<? super HttpServerRequest> condition,
java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
A generic route predicate that if matched invoke the passed I/O handler.
|
default HttpServerRoutes |
ws(java.util.function.Predicate<? super HttpServerRequest> condition,
java.util.function.BiFunction<? super WebsocketInbound,? super WebsocketOutbound,? extends Publisher<Void>> handler,
WebsocketServerSpec websocketServerSpec)
Listens for websocket with the given route predicate to invoke the matching handler.
|
default HttpServerRoutes |
ws(String path,
java.util.function.BiFunction<? super WebsocketInbound,? super WebsocketOutbound,? extends Publisher<Void>> handler)
Listens for websocket on the passed path to be used as a routing condition.
|
default HttpServerRoutes |
ws(String path,
java.util.function.BiFunction<? super WebsocketInbound,? super WebsocketOutbound,? extends Publisher<Void>> handler,
WebsocketServerSpec configurer)
Listens for websocket on the passed path to be used as a routing condition.
|
andThen, apply
static final java.util.function.Predicate<HttpServerRequest> INDEX_PREDICATE
static HttpServerRoutes newRoutes()
HttpServerRoutes
HttpServerRoutes
default HttpServerRoutes delete(String path, java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
Additional regex matching is available, e.g. "/test/{param}".
Params are resolved using HttpServerRequest.param(CharSequence)
path
- The DELETE path used by clients.handler
- an I/O handler to invoke for the given conditionHttpServerRoutes
default HttpServerRoutes directory(String uri, Path directory)
directory
will be served.
Additional regex matching is available, e.g. "/test/{param}". Params are resolved
using HttpServerRequest.param(CharSequence)
uri
- The GET path used by clientsdirectory
- the root prefix to serve from the file system, e.g.
"/Users/me/resources"HttpServerRoutes
HttpServerRoutes directory(String uri, Path directory, @Nullable java.util.function.Function<HttpServerResponse,HttpServerResponse> interceptor)
directory
will be served.
Additional regex matching is available, e.g. "/test/{param}". Params are resolved
using HttpServerRequest.param(CharSequence)
uri
- The GET path used by clientsdirectory
- the root prefix to serve from the file system, e.g.
"/Users/me/resources"interceptor
- a pre response processorHttpServerRoutes
default HttpServerRoutes file(String uri, Path path)
File
will be served.
Additional regex matching is available, e.g. "/test/{param}". Params are resolved
using HttpServerRequest.param(CharSequence)
uri
- The GET path used by clientspath
- the resource Path to serveHttpServerRoutes
default HttpServerRoutes file(String uri, String path)
Additional regex matching is available, e.g. "/test/{param}". Params are resolved
using HttpServerRequest.param(CharSequence)
uri
- The GET path used by clientspath
- the resource path to serveHttpServerRoutes
default HttpServerRoutes file(java.util.function.Predicate<HttpServerRequest> uri, Path path, @Nullable java.util.function.Function<HttpServerResponse,HttpServerResponse> interceptor)
Path
is served.
Additional regex matching is available e.g.
"/test/{param}". Params are resolved using HttpServerRequest.param(CharSequence)
uri
- The HttpPredicate
to use to trigger the route, pattern matching
and capture are supportedpath
- the Path to the file to serveinterceptor
- a channel pre-intercepting handler e.g. for content type headerHttpServerRoutes
default HttpServerRoutes get(String path, java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
Additional regex matching is available e.g.
"/test/{param}". Params are resolved using HttpServerRequest.param(CharSequence)
path
- The GET path used by clientshandler
- an I/O handler to invoke for the given conditionHttpServerRoutes
default HttpServerRoutes head(String path, java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
Additional regex matching is available e.g.
"/test/{param}". Params are resolved using HttpServerRequest.param(CharSequence)
path
- The HEAD path used by clientshandler
- an I/O handler to invoke for the given conditionHttpServerRoutes
default HttpServerRoutes index(java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
handler
- an I/O handler to invoke on index/root requestHttpServerRoutes
default HttpServerRoutes options(String path, java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
Additional regex matching is available e.g.
"/test/{param}". Params are resolved using HttpServerRequest.param(CharSequence)
path
- The OPTIONS path used by clientshandler
- an I/O handler to invoke for the given conditionHttpServerRoutes
default HttpServerRoutes post(String path, java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
Additional regex matching is available e.g.
"/test/{param}". Params are resolved using HttpServerRequest.param(CharSequence)
path
- The POST path used by clientshandler
- an I/O handler to invoke for the given conditionHttpServerRoutes
default HttpServerRoutes put(String path, java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
Additional regex matching is available e.g.
"/test/{param}". Params are resolved using HttpServerRequest.param(CharSequence)
path
- The PUT path used by clientshandler
- an I/O handler to invoke for the given conditionHttpServerRoutes
HttpServerRoutes route(java.util.function.Predicate<? super HttpServerRequest> condition, java.util.function.BiFunction<? super HttpServerRequest,? super HttpServerResponse,? extends Publisher<Void>> handler)
condition
- a predicate given each inbound requesthandler
- the I/O handler to invoke on matchHttpServerRoutes
HttpServerRoutes comparator(Comparator<HttpRouteHandlerMetadata> comparator)
Comparator
to sort routes, rather than using configured order.Routes that were
already configured are also impacted by this change and will be sorted according to the comparator.You can revert
to using the declaration order by calling the noComparator()
method (which is the default).comparator
- a HttpRouteHandlerMetadata comparator.HttpServerRoutes
HttpServerRoutes noComparator()
Comparator
customization using
comparator(Comparator)
, and use the order in which the routes were configured.HttpServerRoutes
default HttpServerRoutes ws(String path, java.util.function.BiFunction<? super WebsocketInbound,? super WebsocketOutbound,? extends Publisher<Void>> handler)
Additional regex matching is available e.g. "/test/{param}".
Params are resolved using HttpServerRequest.param(CharSequence)
They are NOT accessible in the I/O handler provided as parameter.
path
- The websocket path used by clientshandler
- an I/O handler to invoke for the given conditionHttpServerRoutes
default HttpServerRoutes ws(String path, java.util.function.BiFunction<? super WebsocketInbound,? super WebsocketOutbound,? extends Publisher<Void>> handler, WebsocketServerSpec configurer)
Additional regex matching is available e.g. "/test/{param}".
Params are resolved using HttpServerRequest.param(CharSequence)
They are NOT accessible in the handler provided as parameter.
path
- The websocket path used by clientshandler
- an I/O handler to invoke for the given conditionconfigurer
- WebsocketServerSpec
for websocket configurationHttpServerRoutes
default HttpServerRoutes ws(java.util.function.Predicate<? super HttpServerRequest> condition, java.util.function.BiFunction<? super WebsocketInbound,? super WebsocketOutbound,? extends Publisher<Void>> handler, WebsocketServerSpec websocketServerSpec)
condition
- a predicate given each inbound requesthandler
- an I/O handler to invoke for the given conditionwebsocketServerSpec
- WebsocketServerSpec
for websocket configurationHttpServerRoutes