Package io.ktor.server.routing

Types

Link copied to clipboard
data class AndRouteSelector(first: RouteSelector, second: RouteSelector) : RouteSelector

Evaluates a route as a result of the AND operation using two other selectors

Link copied to clipboard
data class ConstantParameterRouteSelector(name: String, value: String) : RouteSelector

Evaluates a route against a constant query parameter value

Link copied to clipboard
data class HostRouteSelector(hostList: List<String>, hostPatterns: List<Regex>, portsList: List<Int>) : RouteSelector

Evaluates a route against a request's host and port

Link copied to clipboard
data class HttpAcceptRouteSelector(contentType: <ERROR CLASS>) : RouteSelector

Evaluates a route against a content-type in the HttpHeaders.Accept header in the request

Link copied to clipboard
data class HttpHeaderRouteSelector(name: String, value: String) : RouteSelector

Evaluates a route against a header in the request

Link copied to clipboard
data class HttpMethodRouteSelector(method: <ERROR CLASS>) : RouteSelector

Evaluates a route against an HttpMethod

Link copied to clipboard
class IgnoreTrailingSlash

Plugin that ignores trailing slashes while resolving urls

Link copied to clipboard
data class LocalPortRouteSelector(port: Int) : RouteSelector

Evaluate a route against the port on which the call was received.

Link copied to clipboard
data class OptionalParameterRouteSelector(name: String) : RouteSelector

Evaluates a route against an optional query parameter value and captures its value, if found

Link copied to clipboard
data class OrRouteSelector(first: RouteSelector, second: RouteSelector) : RouteSelector

Evaluates a route as a result of the OR operation using two other selectors

Link copied to clipboard
data class ParameterRouteSelector(name: String) : RouteSelector

Evaluates a route against a query parameter value and captures its value

Link copied to clipboard
data class PathSegmentConstantRouteSelector(value: String) : RouteSelector

Evaluates a route against a constant path segment

data class PathSegmentOptionalParameterRouteSelector(name: String, prefix: String?, suffix: String?) : RouteSelector

Evaluates a route against an optional parameter path segment and captures its value, if any

Link copied to clipboard
data class PathSegmentParameterRouteSelector(name: String, prefix: String?, suffix: String?) : RouteSelector

Evaluates a route against a parameter path segment and captures its value

Link copied to clipboard
object PathSegmentSelectorBuilder

Helper object for building instances of RouteSelector from path segments

Link copied to clipboard
data class PathSegmentTailcardRouteSelector(name: String, prefix: String) : RouteSelector

Evaluates a route against any number of trailing path segments, and captures their values

Link copied to clipboard
object PathSegmentWildcardRouteSelector : RouteSelector

Evaluates a route against any single path segment

Link copied to clipboard
class RootRouteSelector(rootPath: String) : RouteSelector

The selector for routing root.

Link copied to clipboard
open class Route(parent: Route?, selector: RouteSelector, developmentMode: Boolean, environment: ApplicationEnvironment?) : ApplicationCallPipeline

Describes a node in a routing tree.

Link copied to clipboard
abstract class RouteSelector constructor(quality: Double)

Base type for all routing selectors

Link copied to clipboard
sealed class RouteSelectorEvaluation

Represents a result of a route evaluation against a call

Link copied to clipboard
class Routing(application: Application) : Route

Root routing node for an Application

Link copied to clipboard
class RoutingApplicationCall(call: ApplicationCall, route: Route, coroutineContext: CoroutineContext, receivePipeline: ApplicationReceivePipeline, responsePipeline: ApplicationSendPipeline, parameters: <ERROR CLASS>) : ApplicationCallWithContext

Represents an application call being handled by Routing

Link copied to clipboard

Represents an application request being handled by Routing

Link copied to clipboard

Represents an application response being handled by Routing

Link copied to clipboard
class RoutingPath

Represents a parsed routing path. Consist of number of segments parts

Link copied to clipboard
data class RoutingPathSegment(value: String, kind: RoutingPathSegmentKind)

Represent a single routing path segment

Link copied to clipboard
enum RoutingPathSegmentKind : Enum<RoutingPathSegmentKind>

Possible routing path segment kinds

Link copied to clipboard
class RoutingResolveContext(routing: Route, call: ApplicationCall, tracers: List<(RoutingResolveTrace) -> Unit>)

Represents a context in which routing resolution is being performed

Link copied to clipboard
sealed class RoutingResolveResult

Represents a result of routing resolution.

Link copied to clipboard
class RoutingResolveTrace(call: ApplicationCall, segments: List<String>)

Represents the trace of routing resolution process for diagnostics.

Link copied to clipboard
open class RoutingResolveTraceEntry(route: Route, segmentIndex: Int, result: RoutingResolveResult?)

Represents a single entry in the RoutingResolveTrace.

Link copied to clipboard
object TrailingSlashRouteSelector : RouteSelector

Evaluates a route against a single trailing slash

Functions

Link copied to clipboard
fun Route.accept(contentType: <ERROR CLASS>, build: Route.() -> Unit): Route

Builds a route to match requests with HttpHeaders.Accept header matching specified contentType

Link copied to clipboard
fun Route.contentType(contentType: <ERROR CLASS>, build: Route.() -> Unit): Route

Builds a route to match requests with HttpHeaders.ContentType header matching specified contentType

Link copied to clipboard
fun Route.createRouteFromPath(path: String): Route

Create a routing entry for specified path

Link copied to clipboard
fun Route.delete(body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match DELETE requests

fun Route.delete(path: String, body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match DELETE requests with specified path

Link copied to clipboard
fun Route.get(body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match GET requests

fun Route.get(path: String, body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match GET requests with specified path

Link copied to clipboard
fun Route.head(body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match HEAD requests

fun Route.head(path: String, body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match HEAD requests with specified path

Link copied to clipboard
fun Route.header(name: String, value: String, build: Route.() -> Unit): Route

Builds a route to match header with specified name and value

Link copied to clipboard
fun Route.host(host: String, port: Int = 0, build: Route.() -> Unit): Route
fun Route.host(hosts: List<String>, ports: List<Int> = emptyList(), build: Route.() -> Unit): Route
fun Route.host(hostPattern: Regex, port: Int = 0, build: Route.() -> Unit): Route
fun Route.host(hosts: List<String>, hostPatterns: List<Regex>, ports: List<Int> = emptyList(), build: Route.() -> Unit): Route

Create a route to match request host and port. There are no any host resolutions/transformations applied to a host: a request host is treated as a string.

Link copied to clipboard
fun Route.localPort(port: Int, build: Route.() -> Unit): Route

Create a route to match the port on which the call was received.

Link copied to clipboard
fun Route.method(method: <ERROR CLASS>, body: Route.() -> Unit): Route

Builds a route to match specified method

Link copied to clipboard
fun Route.optionalParam(name: String, build: Route.() -> Unit): Route

Builds a route to optionally capture parameter with specified name, if it exists

Link copied to clipboard
fun Route.options(body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match OPTIONS requests

fun Route.options(path: String, body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match OPTIONS requests with specified path

Link copied to clipboard
fun Route.param(name: String, build: Route.() -> Unit): Route

Builds a route to match parameter with specified name and capture its value

fun Route.param(name: String, value: String, build: Route.() -> Unit): Route

Builds a route to match parameter with specified name and value

Link copied to clipboard
fun Route.patch(body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match PATCH requests

@JvmName(name = "patchTyped")
inline fun <R : Any> Route.patch(crossinline body: suspend <ERROR CLASS><Unit, ApplicationCall>.(R) -> Unit): Route

Builds a route to match PATCH requests receiving request body content of type R

fun Route.patch(path: String, body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match PATCH requests with specified path

@JvmName(name = "patchTypedPath")
inline fun <R : Any> Route.patch(path: String, crossinline body: suspend <ERROR CLASS><Unit, ApplicationCall>.(R) -> Unit): Route

Builds a route to match PATCH requests with specified path receiving request body content of type R

Link copied to clipboard
fun Route.port(vararg ports: Int, build: Route.() -> Unit): Route

Create a route to match request port.

Link copied to clipboard
fun Route.post(body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match POST requests

@JvmName(name = "postTyped")
inline fun <R : Any> Route.post(crossinline body: suspend <ERROR CLASS><Unit, ApplicationCall>.(R) -> Unit): Route

Builds a route to match POST requests receiving request body content of type R

fun Route.post(path: String, body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match POST requests with specified path

@JvmName(name = "postTypedPath")
inline fun <R : Any> Route.post(path: String, crossinline body: suspend <ERROR CLASS><Unit, ApplicationCall>.(R) -> Unit): Route

Builds a route to match POST requests with specified path receiving request body content of type R

Link copied to clipboard
fun Route.put(body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match PUT requests

@JvmName(name = "putTyped")
inline fun <R : Any> Route.put(crossinline body: suspend <ERROR CLASS><Unit, ApplicationCall>.(R) -> Unit): Route

Builds a route to match PUT requests with receiving request body content of type R

fun Route.put(path: String, body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match PUT requests with specified path

@JvmName(name = "putTypedPath")
inline fun <R : Any> Route.put(path: String, crossinline body: suspend <ERROR CLASS><Unit, ApplicationCall>.(R) -> Unit): Route

Builds a route to match PUT requests with specified path receiving request body content of type R

Link copied to clipboard
fun Route.route(path: String, build: Route.() -> Unit): Route

Builds a route to match specified path

fun Route.route(path: String, method: <ERROR CLASS>, build: Route.() -> Unit): Route

Builds a route to match specified method and path

Link copied to clipboard
fun Application.routing(configuration: Routing.() -> Unit): Routing

Gets or installs a Routing plugin for the this Application and runs a configuration script on it

Properties

Link copied to clipboard
val Route.application: Application

Gets an Application for this Route by scanning the hierarchy to the root

Link copied to clipboard
val RoutingFailureStatusCode: <ERROR CLASS><<ERROR CLASS>>