Route

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

Describes a node in a routing tree.

Parameters

parent

is a parent node in the tree, or null for root node.

selector

is an instance of RouteSelector for this node.

developmentMode

is flag to switch report level for stack traces.

Constructors

Link copied to clipboard
fun Route(parent: Route?, selector: RouteSelector, environment: ApplicationEnvironment? = null)

Describes a node in a routing tree.

Link copied to clipboard
fun Route(parent: Route?, selector: RouteSelector, developmentMode: Boolean = false, environment: ApplicationEnvironment? = null)

Functions

Link copied to clipboard
open fun afterIntercepted()
Link copied to clipboard
fun createChild(selector: RouteSelector): Route

Creates a child node in this node with a given selector or returns an existing one with the same selector

Link copied to clipboard
fun handle(handler: <ERROR CLASS><Unit, ApplicationCall>)

Installs a handler into this route which will be called when the route is selected for a call

Link copied to clipboard
operator fun invoke(body: Route.() -> Unit)

Allows using route instance for building additional routes

Link copied to clipboard
open override fun toString(): String

Properties

Link copied to clipboard
val children: List<Route>

List of child routes for this node

Link copied to clipboard
val developmentMode: Boolean = false
Link copied to clipboard
open val environment: ApplicationEnvironment? = null
Link copied to clipboard
val parent: Route?
Link copied to clipboard
val receivePipeline: ApplicationReceivePipeline

Pipeline for receiving content

Link copied to clipboard
val selector: RouteSelector
Link copied to clipboard
val sendPipeline: ApplicationSendPipeline

Pipeline for sending content

Inheritors

Link copied to clipboard

Extensions

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
val Route.application: Application

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

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.default(localPath: String)
fun Route.default(localPath: File)

Specifies localPath as a default file to serve when folder is requested

Link copied to clipboard
fun Route.defaultResource(resource: String, resourcePackage: String? = null)

Specifies resource as a default resources to serve when folder is requested

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

Builds a route to match DELETE requests with specified path

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

Builds a route to match DELETE requests

Link copied to clipboard
fun Route.file(remotePath: String, localPath: String = remotePath)
fun Route.file(remotePath: String, localPath: File)

Sets up routing to serve localPath file as remotePath

Link copied to clipboard
fun Route.files(folder: String)
fun Route.files(folder: File)

Sets up routing to serve all files from folder

Link copied to clipboard
fun <F : Any> Route.findPluginInRoute(plugin: Plugin<*, *, F>): F?
Link copied to clipboard
fun Route.get(path: String, body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match GET requests with specified path

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

Builds a route to match GET requests

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

Builds a route to match HEAD requests with specified path

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

Builds a route to match HEAD requests

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(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.

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(path: String, body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match OPTIONS requests with specified path

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

Builds a route to match OPTIONS requests

Link copied to clipboard
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

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

Builds a route to match PATCH requests with specified path

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

@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(path: String, body: <ERROR CLASS><Unit, ApplicationCall>): Route

Builds a route to match POST requests with specified path

@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

@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

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

Builds a route to match POST requests

Link copied to clipboard
fun Route.preCompressed(vararg types: CompressedFileType = CompressedFileType.values(), configure: Route.() -> Unit)

Support pre-compressed files in the file system only (not just any classpath resource)

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

Builds a route to match PUT requests with specified path

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

@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.resource(remotePath: String, resource: String = remotePath, resourcePackage: String? = null)

Sets up routing to serve resource as remotePath in resourcePackage

Link copied to clipboard
fun Route.resources(resourcePackage: String? = null)

Sets up routing to serve all resources in resourcePackage

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 Route.static(configure: Route.() -> Unit): Route

Create a block for static content

fun Route.static(remotePath: String, configure: Route.() -> Unit): Route

Create a block for static content at specified remotePath

Link copied to clipboard
var Route.staticBasePackage: String?

Base package for relative resources calculations for static content

Link copied to clipboard
var Route.staticRootFolder: File?

Base folder for relative files calculations for static content