class RouterFunctionDsl
Provide a WebFlux.fn RouterFunction Reactive Kotlin DSL created by router { }
in order to be able to write idiomatic Kotlin code.
Author
Sebastien Deleuze
Author
Yevhenii Melnyk
Author
Arjen Poutsma
Since
5.0
accept |
Route to the given handler function if the given accept predicate applies. fun accept(mediaType: MediaType, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Return a RequestPredicate that tests if the request's accept header is compatible with any of the given media types. fun accept(vararg mediaTypes: MediaType): RequestPredicate |
accepted |
Create a builder with an 202 Accepted status. fun accepted(): BodyBuilder |
add |
Merge externally defined router functions into this one. fun add(routerFunction: RouterFunction<ServerResponse>): Unit |
after |
Filter the response object for all routes created by this builder with the given response processing function. Filters are typically used to address cross-cutting concerns, such as logging, security, etc. fun after(responseProcessor: (ServerRequest, ServerResponse) -> ServerResponse): Unit |
and |
Return a composed request predicate that tests against both this predicate AND
the other predicate (String processed as a path predicate). When evaluating the
composed predicate, if this predicate is infix fun RequestPredicate.and(other: String): RequestPredicate
Return a composed request predicate that tests against both this predicate (String
processed as a path predicate) AND the other predicate. When evaluating the
composed predicate, if this predicate is infix fun String.and(other: RequestPredicate): RequestPredicate
Return a composed request predicate that tests against both this predicate AND
the other predicate. When evaluating the composed predicate, if this
predicate is infix fun RequestPredicate.and(other: RequestPredicate): RequestPredicate |
badRequest |
Create a builder with a 400 Bad Request status. fun badRequest(): BodyBuilder |
before |
Filter the request object for all routes created by this builder with the given request processing function. Filters are typically used to address cross-cutting concerns, such as logging, security, etc. fun before(requestProcessor: (ServerRequest) -> ServerRequest): Unit |
contentType |
Route to the given handler function if the given contentType predicate applies. fun contentType(mediaTypes: MediaType, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Return a RequestPredicate that tests if the request's content type is included by any of the given media types. fun contentType(vararg mediaTypes: MediaType): RequestPredicate |
created |
Create a new builder with a 201 Created status and a location header set to the given URI. fun created(location: URI): BodyBuilder |
DELETE |
Adds a route to the given handler function that handles all HTTP fun DELETE(f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun DELETE(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun DELETE(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun DELETE(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Return a RequestPredicate that matches if request's HTTP method is fun DELETE(pattern: String): RequestPredicate |
filter |
Filters all routes created by this router with the given filter function. Filter functions are typically used to address cross-cutting concerns, such as logging, security, etc. fun filter(filterFunction: (ServerRequest, (ServerRequest) -> Mono<ServerResponse>) -> Mono<ServerResponse>): Unit |
from |
Create a builder with the status code and headers of the given response. fun from(other: ServerResponse): BodyBuilder |
GET |
Adds a route to the given handler function that handles all HTTP fun GET(f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun GET(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun GET(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun GET(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Return a RequestPredicate that matches if request's HTTP method is fun GET(pattern: String): RequestPredicate |
HEAD |
Adds a route to the given handler function that handles all HTTP fun HEAD(f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun HEAD(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun HEAD(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun HEAD(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Return a RequestPredicate that matches if request's HTTP method is fun HEAD(pattern: String): RequestPredicate |
headers |
Route to the given handler function if the given headers predicate applies. fun headers(headersPredicate: (Headers) -> Boolean, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Return a RequestPredicate that tests the request's headers against the given headers predicate. fun headers(headersPredicate: (Headers) -> Boolean): RequestPredicate |
invoke |
Route to the given handler function if the given request predicate applies. operator fun RequestPredicate.invoke(f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Route to the given handler function if the given predicate (String processed as a path predicate) applies. operator fun String.invoke(f: (ServerRequest) -> Mono<out ServerResponse>): Unit |
method |
Route to the given handler function if the given method predicate applies. fun method(httpMethod: HttpMethod, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Return a RequestPredicate that tests against the given HTTP method. fun method(httpMethod: HttpMethod): RequestPredicate |
nest |
Route to the given router function if the given request predicate applies. This method can be used to create nested routes, where a group of routes share a common path (prefix), header, or other request predicate. fun RequestPredicate.nest(init: RouterFunctionDsl.() -> Unit): Unit
Route to the given router function if the given request predicate (String processed as a path predicate) applies. This method can be used to create nested routes, where a group of routes share a common path (prefix), header, or other request predicate. fun String.nest(init: RouterFunctionDsl.() -> Unit): Unit |
noContent |
Create a builder with a 204 No Content status. fun noContent(): HeadersBuilder<*> |
not |
Return a predicate that represents the logical negation of this predicate. operator fun RequestPredicate.not(): RequestPredicate |
notFound |
Create a builder with a 404 Not Found status. fun notFound(): HeadersBuilder<*> |
ok |
Create a builder with the status set to 200 OK. fun ok(): BodyBuilder |
onError |
Filters all exceptions that match the predicate by applying the given response provider function. fun onError(predicate: (Throwable) -> Boolean, responseProvider: (Throwable, ServerRequest) -> Mono<ServerResponse>): Unit fun <E : Throwable> onError(responseProvider: (Throwable, ServerRequest) -> Mono<ServerResponse>): Unit |
OPTIONS |
Adds a route to the given handler function that handles all HTTP fun OPTIONS(f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun OPTIONS(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun OPTIONS(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun OPTIONS(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Return a RequestPredicate that matches if request's HTTP method is fun OPTIONS(pattern: String): RequestPredicate |
or |
Return a composed request predicate that tests against both this predicate OR
the other predicate (String processed as a path predicate). When evaluating the
composed predicate, if this predicate is infix fun RequestPredicate.or(other: String): RequestPredicate
Return a composed request predicate that tests against both this predicate (String
processed as a path predicate) OR the other predicate. When evaluating the
composed predicate, if this predicate is infix fun String.or(other: RequestPredicate): RequestPredicate
Return a composed request predicate that tests against both this predicate OR
the other predicate. When evaluating the composed predicate, if this
predicate is infix fun RequestPredicate.or(other: RequestPredicate): RequestPredicate |
PATCH |
Adds a route to the given handler function that handles all HTTP fun PATCH(f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun PATCH(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun PATCH(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun PATCH(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Return a RequestPredicate that matches if request's HTTP method is fun PATCH(pattern: String): RequestPredicate |
path |
Route to the given handler function if the given path predicate applies. fun path(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Return a RequestPredicate that tests the request path against the given path pattern. fun path(pattern: String): RequestPredicate |
pathExtension |
Route to the given handler function if the given pathExtension predicate applies. fun pathExtension(extension: String, f: (ServerRequest) -> Mono<out ServerResponse>): Unit fun pathExtension(predicate: (String) -> Boolean, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Return a RequestPredicate that matches if the request's path has the given extension. fun pathExtension(extension: String): RequestPredicate
Return a RequestPredicate that matches if the request's path matches the given predicate. fun pathExtension(predicate: (String) -> Boolean): RequestPredicate |
permanentRedirect |
Create a builder with a 308 Permanent Redirect status and a location header set to the given URI. fun permanentRedirect(location: URI): BodyBuilder |
POST |
Adds a route to the given handler function that handles all HTTP fun POST(f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun POST(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun POST(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun POST(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Return a RequestPredicate that matches if request's HTTP method is fun POST(pattern: String): RequestPredicate |
PUT |
Adds a route to the given handler function that handles all HTTP fun PUT(f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun PUT(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun PUT(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Adds a route to the given handler function that handles all HTTP fun PUT(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Return a RequestPredicate that matches if request's HTTP method is fun PUT(pattern: String): RequestPredicate |
queryParam |
Route to the given handler function if the given queryParam predicate applies. fun queryParam(name: String, predicate: (String) -> Boolean, f: (ServerRequest) -> Mono<out ServerResponse>): Unit
Return a RequestPredicate that tests the request's query parameter of the given name against the given predicate. fun queryParam(name: String, predicate: (String) -> Boolean): RequestPredicate |
resources |
Route requests that match the given pattern to resources relative to the given root location. fun resources(path: String, location: Resource): Unit
Route to resources using the provided lookup function. If the lookup function provides a Resource for the given request, it will be it will be exposed using a HandlerFunction that handles GET, HEAD, and OPTIONS requests. fun resources(lookupFunction: (ServerRequest) -> Mono<Resource>): Unit |
seeOther |
Create a builder with a 303 See Other status and a location header set to the given URI. fun seeOther(location: URI): BodyBuilder |
status |
Create a builder with the given HTTP status. fun status(status: HttpStatus): BodyBuilder fun status(status: Int): BodyBuilder |
temporaryRedirect |
Create a builder with a 307 Temporary Redirect status and a location header set to the given URI. fun temporaryRedirect(location: URI): BodyBuilder |
unprocessableEntity |
Create a builder with an 422 Unprocessable Entity status. fun unprocessableEntity(): BodyBuilder |