public interface HttpServerRoutes extends BiFunction<HttpServerRequest,HttpServerResponse,Publisher<Void>>
Modifier and Type | Field and Description |
---|---|
static 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,
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,
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(Predicate<HttpServerRequest> uri,
Path path,
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,
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,
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(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,
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,
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,
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 |
removeIf(Predicate<? super HttpRouteHandlerMetadata> condition)
A generic route predicate that if matched already register I/O handler use
route(Predicate, BiFunction) will be removed. |
HttpServerRoutes |
route(Predicate<? super HttpServerRequest> condition,
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(Predicate<? super HttpServerRequest> condition,
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,
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,
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 Predicate<HttpServerRequest> INDEX_PREDICATE
static HttpServerRoutes newRoutes()
HttpServerRoutes
.HttpServerRoutes
default HttpServerRoutes delete(String path, 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 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(Predicate<HttpServerRequest> uri, Path path, @Nullable 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, 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, 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(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, 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, 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, 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 removeIf(Predicate<? super HttpRouteHandlerMetadata> condition)
route(Predicate, BiFunction)
will be removed.condition
- a predicate given each http route handler HttpRouteHandlerMetadata
HttpServerRoutes
HttpServerRoutes route(Predicate<? super HttpServerRequest> condition, 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, 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, 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(Predicate<? super HttpServerRequest> condition, 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