route

fun Routing.route(path: Regex, build: Routing.() -> Unit): Routing

Builds a route to match the specified regex path. Named parameters from regex can be accessed via ApplicationCall.parameters.

Example:

route(Regex("/(?<number>\\d+)")) {
    get("/hello") {
        val number = call.parameters["number"]
        ...
    }
}

fun Routing.route(path: Regex, method: HttpMethod, build: Routing.() -> Unit): Routing

Builds a route to match the specified HTTP method and regex path. Named parameters from regex can be accessed via ApplicationCall.parameters.

Example:

route(Regex("/(?<name>.+)/hello"), HttpMethod.Get) {
    handle {
        val name = call.parameters["name"]
        ...
    }
}

fun Routing.route(path: String, build: Routing.() -> Unit): Routing

Builds a route to match the specified path.

See also


fun Routing.route(path: String, method: HttpMethod, build: Routing.() -> Unit): Routing

Builds a route to match the specified HTTP method and path.

See also