class CoRouterFunctionDsl
Provide a WebFlux.fn RouterFunction Coroutines Kotlin DSL created by coRouter { }
in order to be able to write idiomatic Kotlin code.
Author
Sebastien Deleuze
Since
5.2
CoRouterFunctionDsl(init: CoRouterFunctionDsl.() -> Unit)
Provide a WebFlux.fn RouterFunction Coroutines Kotlin DSL created by |
fun accept(mediaType: MediaType, f: suspend (ServerRequest) -> ServerResponse): Unit
Route to the given handler function if the given accept predicate applies. fun accept(vararg mediaType: MediaType): RequestPredicate
Return a RequestPredicate that tests if the request's accept } header is compatible with any of the given media types. |
|
fun accepted(): BodyBuilder! |
|
fun add(routerFunction: RouterFunction<ServerResponse>): Unit
Merge externally defined router functions into this one. |
|
fun after(responseProcessor: (ServerRequest, ServerResponse) -> ServerResponse): Unit
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. |
|
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). 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 (String
processed as a path predicate) AND the other predicate. When evaluating the
composed predicate, if this predicate is infix fun RequestPredicate.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 |
|
fun badRequest(): BodyBuilder! |
|
fun before(requestProcessor: (ServerRequest) -> ServerRequest): Unit
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 contentType(mediaType: MediaType, f: suspend (ServerRequest) -> ServerResponse): Unit
Route to the given handler function if the given contentType predicate applies. 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 created(location: URI): BodyBuilder! |
|
fun DELETE(pattern: String, f: suspend (ServerRequest) -> ServerResponse): Unit fun DELETE(pattern: String, predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse): Unit
Adds a route to the given handler function that handles all HTTP fun DELETE(pattern: String): RequestPredicate
Return a RequestPredicate that matches if request's HTTP method is |
|
fun filter(filterFunction: suspend (ServerRequest, suspend (ServerRequest) -> ServerResponse) -> ServerResponse): Unit
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 from(other: ServerResponse): BodyBuilder! |
|
fun GET(pattern: String, f: suspend (ServerRequest) -> ServerResponse): Unit fun GET(pattern: String, predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse): Unit
Adds a route to the given handler function that handles all HTTP fun GET(pattern: String): RequestPredicate
Return a RequestPredicate that matches if request's HTTP method is |
|
fun HEAD(pattern: String, f: suspend (ServerRequest) -> ServerResponse): Unit fun HEAD(pattern: String, predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse): Unit
Adds a route to the given handler function that handles all HTTP fun HEAD(pattern: String): RequestPredicate
Return a RequestPredicate that matches if request's HTTP method is |
|
fun headers(headersPredicate: (Headers) -> Boolean, f: suspend (ServerRequest) -> ServerResponse): Unit
Route to the given handler function if the given headers predicate applies. fun headers(headersPredicate: (Headers) -> Boolean): RequestPredicate
Return a RequestPredicate that tests the request's headers against the given headers predicate. |
|
operator fun RequestPredicate.invoke(f: suspend (ServerRequest) -> ServerResponse): Unit
Route to the given handler function if the given request predicate applies. operator fun String.invoke(f: suspend (ServerRequest) -> ServerResponse): Unit
Route to the given handler function if the given predicate (String processed as a path predicate) applies. |
|
fun method(httpMethod: HttpMethod, f: suspend (ServerRequest) -> ServerResponse): Unit
Route to the given handler function if the given method predicate applies. fun method(httpMethod: HttpMethod): RequestPredicate
Return a RequestPredicate that tests against the given HTTP method. |
|
fun RequestPredicate.nest(r: CoRouterFunctionDsl.() -> Unit): Unit
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 String.nest(r: CoRouterFunctionDsl.() -> 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 noContent(): HeadersBuilder<*>! |
|
operator fun RequestPredicate.not(): RequestPredicate
Return a predicate that represents the logical negation of this predicate. |
|
fun notFound(): HeadersBuilder<*>! |
|
fun ok(): BodyBuilder! |
|
fun onError(predicate: (Throwable) -> Boolean, responseProvider: suspend (Throwable, ServerRequest) -> ServerResponse): Unit fun <E : Throwable> onError(responseProvider: suspend (Throwable, ServerRequest) -> ServerResponse): Unit
Filters all exceptions that match the predicate by applying the given response provider function. |
|
fun OPTIONS(pattern: String, f: suspend (ServerRequest) -> ServerResponse): Unit fun OPTIONS(pattern: String, predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse): Unit
Adds a route to the given handler function that handles all HTTP fun OPTIONS(pattern: String): RequestPredicate
Return a RequestPredicate that matches if request's HTTP method is |
|
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). 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 (String
processed as a path predicate) OR the other predicate. When evaluating the
composed predicate, if this predicate is infix fun RequestPredicate.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 |
|
fun PATCH(pattern: String, f: suspend (ServerRequest) -> ServerResponse): Unit fun PATCH(pattern: String, predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse): Unit
Adds a route to the given handler function that handles all HTTP fun PATCH(pattern: String): RequestPredicate
Return a RequestPredicate that matches if request's HTTP method is |
|
fun path(pattern: String, f: suspend (ServerRequest) -> ServerResponse): Unit
Route to the given handler function if the given path predicate applies. fun path(pattern: String): RequestPredicate
Return a RequestPredicate that tests the request path against the given path pattern. |
|
fun pathExtension(extension: String, f: suspend (ServerRequest) -> ServerResponse): Unit fun pathExtension(predicate: (String) -> Boolean, f: suspend (ServerRequest) -> ServerResponse): Unit
Route to the given handler function if the given pathExtension predicate applies. fun pathExtension(extension: String): RequestPredicate
Return a RequestPredicate that matches if the request's path has the given extension. fun pathExtension(predicate: (String) -> Boolean): RequestPredicate
Return a RequestPredicate that matches if the request's path matches the given predicate. |
|
fun permanentRedirect(location: URI): BodyBuilder! |
|
fun POST(pattern: String, f: suspend (ServerRequest) -> ServerResponse): Unit fun POST(pattern: String, predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse): Unit
Adds a route to the given handler function that handles all HTTP fun POST(pattern: String): RequestPredicate
Return a RequestPredicate that matches if request's HTTP method is |
|
fun PUT(pattern: String, f: suspend (ServerRequest) -> ServerResponse): Unit fun PUT(pattern: String, predicate: RequestPredicate, f: suspend (ServerRequest) -> ServerResponse): Unit
Adds a route to the given handler function that handles all HTTP fun PUT(pattern: String): RequestPredicate
Return a RequestPredicate that matches if request's HTTP method is |
|
fun queryParam(name: String, predicate: (String) -> Boolean, f: suspend (ServerRequest) -> ServerResponse): Unit
Route to the given handler function if the given queryParam predicate applies. 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 resources(path: String, location: Resource): Unit
Route requests that match the given pattern to resources relative to the given root location. fun resources(lookupFunction: suspend (ServerRequest) -> 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 seeOther(location: URI): BodyBuilder! |
|
fun status(status: HttpStatus): BodyBuilder! fun status(status: Int): BodyBuilder! |
|
fun temporaryRedirect(location: URI): BodyBuilder! |
|
fun unprocessableEntity(): BodyBuilder! |