RouterFunctionDsl

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

Yevhenii Melnyk

Arjen Poutsma

Since

5.0

Functions

accept
Link copied to clipboard
fun accept(vararg mediaTypes: MediaType): RequestPredicate
Return a RequestPredicate that tests if the request's accept header is compatible with any of the given media types.
fun accept(mediaType: MediaType, f: (ServerRequest) -> Mono<out ServerResponse>)
Route to the given handler function if the given accept predicate applies.
accepted
Link copied to clipboard
fun accepted(): ServerResponse.BodyBuilder
Create a builder with an 202 Accepted status.
add
Link copied to clipboard
fun add(routerFunction: RouterFunction<ServerResponse>)
Merge externally defined router functions into this one.
after
Link copied to clipboard
fun after(responseProcessor: (ServerRequest, ServerResponse) -> ServerResponse)
Filter the response object for all routes created by this builder with the given response processing function.
and
Link copied to clipboard
infix fun String.and(other: RequestPredicate): RequestPredicate
Return a composed request predicate that tests against both this predicate (String processed as a path predicate) AND the other predicate.
infix fun RequestPredicate.and(other: String): RequestPredicate
Return a composed request predicate that tests against both this predicate AND the other predicate (String processed as a path predicate).
infix fun RequestPredicate.and(other: RequestPredicate): RequestPredicate
Return a composed request predicate that tests against both this predicate AND the other predicate.
badRequest
Link copied to clipboard
fun badRequest(): ServerResponse.BodyBuilder
Create a builder with a 400 Bad Request status.
before
Link copied to clipboard
fun before(requestProcessor: (ServerRequest) -> ServerRequest)
Filter the request object for all routes created by this builder with the given request processing function.
contentType
Link copied to clipboard
fun contentType(vararg mediaTypes: MediaType): RequestPredicate
Return a RequestPredicate that tests if the request's content type is included by any of the given media types.
fun contentType(mediaTypes: MediaType, f: (ServerRequest) -> Mono<out ServerResponse>)
Route to the given handler function if the given contentType predicate applies.
created
Link copied to clipboard
fun created(location: URI): ServerResponse.BodyBuilder
Create a new builder with a 201 Created status and a location header set to the given URI.
DELETE
Link copied to clipboard
fun DELETE(f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP DELETE requests.
fun DELETE(pattern: String): RequestPredicate
Return a RequestPredicate that matches if request's HTTP method is DELETE and the given pattern matches against the request path.
fun DELETE(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP DELETE requests that match the given pattern.
fun DELETE(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP DELETE requests that match the given predicate.
fun DELETE(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP DELETE requests that match the given pattern and predicate.
filter
Link copied to clipboard
fun filter(filterFunction: (ServerRequest, (ServerRequest) -> Mono<ServerResponse>) -> Mono<ServerResponse>)
Filters all routes created by this router with the given filter function.
from
Link copied to clipboard
fun from(other: ServerResponse): ServerResponse.BodyBuilder
Create a builder with the status code and headers of the given response.
GET
Link copied to clipboard
fun GET(f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP GET requests.
fun GET(pattern: String): RequestPredicate
Return a RequestPredicate that matches if request's HTTP method is GET and the given pattern matches against the request path.
fun GET(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP GET requests that match the given pattern.
fun GET(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP GET requests that match the given predicate.
fun GET(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP GET requests that match the given pattern and predicate.
HEAD
Link copied to clipboard
fun HEAD(f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP HEAD requests.
fun HEAD(pattern: String): RequestPredicate
Return a RequestPredicate that matches if request's HTTP method is HEAD and the given pattern matches against the request path.
fun HEAD(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP HEAD requests that match the given pattern.
fun HEAD(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP HEAD requests that match the given predicate.
fun HEAD(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP HEAD requests that match the given pattern and predicate.
headers
Link copied to clipboard
fun headers(headersPredicate: (ServerRequest.Headers) -> Boolean): RequestPredicate
Return a RequestPredicate that tests the request's headers against the given headers predicate.
fun headers(headersPredicate: (ServerRequest.Headers) -> Boolean, f: (ServerRequest) -> Mono<out ServerResponse>)
Route to the given handler function if the given headers predicate applies.
invoke
Link copied to clipboard
operator fun String.invoke(f: (ServerRequest) -> Mono<out ServerResponse>)
Route to the given handler function if the given predicate (String processed as a path predicate) applies.
operator fun RequestPredicate.invoke(f: (ServerRequest) -> Mono<out ServerResponse>)
Route to the given handler function if the given request predicate applies.
method
Link copied to clipboard
fun method(httpMethod: HttpMethod): RequestPredicate
Return a RequestPredicate that tests against the given HTTP method.
fun method(httpMethod: HttpMethod, f: (ServerRequest) -> Mono<out ServerResponse>)
Route to the given handler function if the given method predicate applies.
nest
Link copied to clipboard
fun String.nest(init: RouterFunctionDsl.() -> Unit)
Route to the given router function if the given request predicate (String processed as a path predicate) applies.
fun RequestPredicate.nest(init: RouterFunctionDsl.() -> Unit)
Route to the given router function if the given request predicate applies.
noContent
Link copied to clipboard
fun noContent(): ServerResponse.HeadersBuilder<*>
Create a builder with a 204 No Content status.
not
Link copied to clipboard
operator fun RequestPredicate.not(): RequestPredicate
Return a predicate that represents the logical negation of this predicate.
notFound
Link copied to clipboard
fun notFound(): ServerResponse.HeadersBuilder<*>
Create a builder with a 404 Not Found status.
ok
Link copied to clipboard
fun ok(): ServerResponse.BodyBuilder
Create a builder with the status set to 200 OK.
onError
Link copied to clipboard
inline fun <E : Throwable> onError(noinline responseProvider: (Throwable, ServerRequest) -> Mono<ServerResponse>)
Filters all exceptions that match the predicate by applying the given response provider function.
fun onError(predicate: (Throwable) -> Boolean, responseProvider: (Throwable, ServerRequest) -> Mono<ServerResponse>)
Filters all exceptions that match the predicate by applying the given response provider function.
OPTIONS
Link copied to clipboard
fun OPTIONS(f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP OPTIONS requests.
fun OPTIONS(pattern: String): RequestPredicate
Return a RequestPredicate that matches if request's HTTP method is OPTIONS and the given pattern matches against the request path.
fun OPTIONS(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP OPTIONS requests that match the given pattern.
fun OPTIONS(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP OPTIONS requests that match the given predicate.
fun OPTIONS(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP OPTIONS requests that match the given pattern and predicate.
or
Link copied to clipboard
infix fun String.or(other: RequestPredicate): RequestPredicate
Return a composed request predicate that tests against both this predicate (String processed as a path predicate) OR the other predicate.
infix fun RequestPredicate.or(other: String): RequestPredicate
Return a composed request predicate that tests against both this predicate OR the other predicate (String processed as a path predicate).
infix fun RequestPredicate.or(other: RequestPredicate): RequestPredicate
Return a composed request predicate that tests against both this predicate OR the other predicate.
PATCH
Link copied to clipboard
fun PATCH(f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP PATCH requests.
fun PATCH(pattern: String): RequestPredicate
Return a RequestPredicate that matches if request's HTTP method is PATCH and the given pattern matches against the request path.
fun PATCH(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP PATCH requests that match the given pattern.
fun PATCH(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP PATCH requests that match the given predicate.
fun PATCH(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP PATCH requests that match the given pattern and predicate.
path
Link copied to clipboard
fun path(pattern: String): RequestPredicate
Return a RequestPredicate that tests the request path against the given path pattern.
fun path(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>)
Route to the given handler function if the given path predicate applies.
pathExtension
Link copied to clipboard
fun pathExtension(predicate: (String) -> Boolean): RequestPredicate
Return a RequestPredicate that matches if the request's path matches the given predicate.
fun pathExtension(extension: String): RequestPredicate
Return a RequestPredicate that matches if the request's path has the given extension.
fun pathExtension(predicate: (String) -> Boolean, f: (ServerRequest) -> Mono<out ServerResponse>)
Route to the given handler function if the given pathExtension predicate applies.
fun pathExtension(extension: String, f: (ServerRequest) -> Mono<out ServerResponse>)
Route to the given handler function if the given pathExtension predicate applies.
permanentRedirect
Link copied to clipboard
fun permanentRedirect(location: URI): ServerResponse.BodyBuilder
Create a builder with a 308 Permanent Redirect status and a location header set to the given URI.
POST
Link copied to clipboard
fun POST(f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP POST requests.
fun POST(pattern: String): RequestPredicate
Return a RequestPredicate that matches if request's HTTP method is POST and the given pattern matches against the request path.
fun POST(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP POST requests that match the given pattern.
fun POST(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP POST requests that match the given predicate.
fun POST(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP POST requests that match the given pattern and predicate.
PUT
Link copied to clipboard
fun PUT(f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP PUT requests.
fun PUT(pattern: String): RequestPredicate
Return a RequestPredicate that matches if request's HTTP method is PUT and the given pattern matches against the request path.
fun PUT(pattern: String, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP PUT requests that match the given pattern.
fun PUT(predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP PUT requests that match the given predicate.
fun PUT(pattern: String, predicate: RequestPredicate, f: (ServerRequest) -> Mono<out ServerResponse>)
Adds a route to the given handler function that handles all HTTP PUT requests that match the given pattern and predicate.
queryParam
Link copied to clipboard
fun queryParam(name: String, predicate: (String) -> Boolean): RequestPredicate
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, f: (ServerRequest) -> Mono<out ServerResponse>)
Route to the given handler function if the given queryParam predicate applies.
resources
Link copied to clipboard
fun resources(lookupFunction: (ServerRequest) -> Mono<Resource>)
Route to resources using the provided lookup function.
fun resources(path: String, location: Resource)
Route requests that match the given pattern to resources relative to the given root location.
seeOther
Link copied to clipboard
fun seeOther(location: URI): ServerResponse.BodyBuilder
Create a builder with a 303 See Other status and a location header set to the given URI.
status
Link copied to clipboard
fun status(status: Int): ServerResponse.BodyBuilder
Create a builder with the given HTTP status.
fun status(status: HttpStatus): ServerResponse.BodyBuilder
Create a builder with the given HTTP status.
temporaryRedirect
Link copied to clipboard
fun temporaryRedirect(location: URI): ServerResponse.BodyBuilder
Create a builder with a 307 Temporary Redirect status and a location header set to the given URI.
unprocessableEntity
Link copied to clipboard
fun unprocessableEntity(): ServerResponse.BodyBuilder
Create a builder with an 422 Unprocessable Entity status.