Package io.ktor.routing

Types

AndRouteSelector

data class AndRouteSelector : RouteSelector

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

ConstantParameterRouteSelector

data class ConstantParameterRouteSelector : RouteSelector

Evaluates a route against a constant query parameter value

HostRouteSelector

data class HostRouteSelector : RouteSelector

Evaluates a route against a request’s host and port

HttpAcceptRouteSelector

data class HttpAcceptRouteSelector : RouteSelector

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

HttpHeaderRouteSelector

data class HttpHeaderRouteSelector : RouteSelector

Evaluates a route against a header in the request

HttpMethodRouteSelector

data class HttpMethodRouteSelector : RouteSelector

Evaluates a route against an HttpMethod

OptionalParameterRouteSelector

data class OptionalParameterRouteSelector : RouteSelector

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

OrRouteSelector

data class OrRouteSelector : RouteSelector

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

ParameterRouteSelector

data class ParameterRouteSelector : RouteSelector

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

PathSegmentConstantRouteSelector

data class PathSegmentConstantRouteSelector : RouteSelector

Evaluates a route against a constant path segment

PathSegmentOptionalParameterRouteSelector

data class PathSegmentOptionalParameterRouteSelector : 
    RouteSelector

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

PathSegmentParameterRouteSelector

data class PathSegmentParameterRouteSelector : RouteSelector

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

PathSegmentSelectorBuilder

object PathSegmentSelectorBuilder

Helper object for building instances of RouteSelector from path segments

PathSegmentTailcardRouteSelector

data class PathSegmentTailcardRouteSelector : RouteSelector

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

PathSegmentWildcardRouteSelector

object PathSegmentWildcardRouteSelector : RouteSelector

Evaluates a route against any single path segment

RootRouteSelector

class RootRouteSelector : RouteSelector

The selector for routing root.

Route

open class Route : ApplicationCallPipeline

Describes a node in a routing tree

RouteSelector

abstract class RouteSelector

Base type for all routing selectors

RouteSelectorEvaluation

data class RouteSelectorEvaluation

Represents a result of a route evaluation against a call

Routing

class Routing : Route

Root routing node for an Application

RoutingApplicationCall

class RoutingApplicationCall : ApplicationCall

Represents an application call being handled by Routing

RoutingApplicationRequest

class RoutingApplicationRequest : ApplicationRequest

Represents an application request being handled by Routing

RoutingApplicationResponse

class RoutingApplicationResponse : ApplicationResponse

Represents an application response being handled by Routing

RoutingPath

class RoutingPath

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

RoutingPathSegment

data class RoutingPathSegment

Represent a single routing path segment

RoutingPathSegmentKind

enum class RoutingPathSegmentKind

Possible routing path segment kinds

RoutingResolveContext

class RoutingResolveContext

Represents a context in which routing resolution is being performed

RoutingResolveResult

sealed class RoutingResolveResult

Represents a result of routing resolution.

RoutingResolveTrace

class RoutingResolveTrace

Represents the trace of routing resolution process for diagnostics.

RoutingResolveTraceEntry

open class RoutingResolveTraceEntry

Represents a single entry in the RoutingResolveTrace.

Properties

application

val Route.application: Application

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

Functions

accept

fun Route.accept(
    contentType: ContentType,
    build: Route.() -> Unit
): Route

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

contentType

fun Route.contentType(
    contentType: ContentType,
    build: Route.() -> Unit
): Route

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

createRouteFromPath

fun Route.createRouteFromPath(path: String): Route

Create a routing entry for specified path

delete

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

Builds a route to match DELETE requests with specified path

fun Route.delete(
    body: PipelineInterceptor<Unit, ApplicationCall>
): Route

Builds a route to match DELETE requests

get

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

Builds a route to match GET requests with specified path

fun Route.get(
    body: PipelineInterceptor<Unit, ApplicationCall>
): Route

Builds a route to match GET requests

head

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

Builds a route to match HEAD requests with specified path

fun Route.head(
    body: PipelineInterceptor<Unit, ApplicationCall>
): Route

Builds a route to match HEAD requests

header

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

Builds a route to match header with specified name and value

host

fun Route.host(
    host: String,
    port: Int = 0,
    build: Route.() -> Unit
): Route
fun Route.host(
    hostPattern: Regex,
    port: Int = 0,
    build: Route.() -> Unit
): Route
fun Route.host(
    hosts: List<String>,
    ports: List<Int> = emptyList(),
    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.

method

fun Route.method(
    method: HttpMethod,
    body: Route.() -> Unit
): Route

Builds a route to match specified method

optionalParam

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

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

options

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

Builds a route to match OPTIONS requests with specified path

fun Route.options(
    body: PipelineInterceptor<Unit, ApplicationCall>
): Route

Builds a route to match OPTIONS requests

param

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

Builds a route to match parameter with specified name and value

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

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

patch

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

Builds a route to match PATCH requests with specified path

fun Route.patch(
    body: PipelineInterceptor<Unit, ApplicationCall>
): Route

Builds a route to match PATCH requests

port

fun Route.port(
    vararg ports: Int,
    build: Route.() -> Unit
): Route

Create a route to match request port.

post

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

Builds a route to match POST requests with specified path

fun <R : Any> Route.post(
    path: String,
    body: suspend PipelineContext<Unit, ApplicationCall>.(R) -> Unit
): Route

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

fun Route.post(
    body: PipelineInterceptor<Unit, ApplicationCall>
): Route

Builds a route to match POST requests

put

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

Builds a route to match PUT requests with specified path

fun Route.put(
    body: PipelineInterceptor<Unit, ApplicationCall>
): Route

Builds a route to match PUT requests

route

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

Builds a route to match specified path

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

Builds a route to match specified method and path

routing

fun Application.routing(
    configuration: Routing.() -> Unit
): Routing

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