RootRouting

interface RootRouting : Routing

A builder for a routing tree root.

Inheritors

Properties

Link copied to clipboard

Gets an Application for this RoutingNode by scanning the hierarchy to the root.

Link copied to clipboard
abstract val attributes: Attributes
Link copied to clipboard
Link copied to clipboard
abstract val parent: Routing?
Link copied to clipboard

Base package for relative resources calculations for static content

Link copied to clipboard

Base folder for relative files calculations for static content

Functions

Link copied to clipboard
fun Routing.accept(vararg contentTypes: ContentType, build: Routing.() -> Unit): Routing

Builds a route to match requests with the HttpHeaders.Accept header matching any of the specified contentTypes.

Link copied to clipboard
fun Routing.contentType(contentType: ContentType, build: Routing.() -> Unit): Routing

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

Link copied to clipboard
abstract fun createChild(selector: RouteSelector): Routing

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

Link copied to clipboard

Creates a routing entry for the specified path.

Link copied to clipboard
fun Routing.default(localPath: File)
fun Routing.default(localPath: String)

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

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

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

Link copied to clipboard

Builds a route to match DELETE requests.

Builds a route to match DELETE requests with the specified path.

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

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

Sets up routing to serve localPath file as remotePath

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

Sets up routing to serve all files from folder

Link copied to clipboard

Builds a route to match GET requests.

Builds a route to match GET requests with the specified path.

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

Link copied to clipboard
abstract fun handle(body: RoutingHandler)

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

Link copied to clipboard

Builds a route to match HEAD requests.

Builds a route to match HEAD requests with the specified path.

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

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

Builds a route to match a header with the specified name and value.

Link copied to clipboard
fun Routing.host(host: String, port: Int = 0, build: Routing.() -> Unit): Routing

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

fun Routing.host(hosts: List<String>, ports: List<Int> = emptyList(), build: Routing.() -> Unit): Routing
fun Routing.host(hostPattern: Regex, port: Int = 0, build: Routing.() -> Unit): Routing

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

fun Routing.host(hosts: List<String>, hostPatterns: List<Regex>, ports: List<Int> = emptyList(), build: Routing.() -> Unit): Routing

Creates a route to match s 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
Link copied to clipboard
Link copied to clipboard
abstract fun <B : Any, F : Any> install(plugin: Plugin<ApplicationCallPipeline, B, F>, configure: B.() -> Unit = {}): F

Installs a plugin into this route, if it is not yet installed.

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

Creates a route to match a port on which a call was received.

Link copied to clipboard
fun Routing.method(method: HttpMethod, body: Routing.() -> Unit): Routing

Builds a route to match the specified HTTP method.

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

Builds a route to capture an optional parameter with specified name, if it exists.

Link copied to clipboard

Builds a route to match OPTIONS requests.

Builds a route to match OPTIONS requests with the specified path.

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

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

Builds a route to match a parameter with the specified name and captures its value.

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

Builds a route to match a parameter with the specified name and value.

Link copied to clipboard

Builds a route to match PATCH requests.

@JvmName(name = "patchTyped")
inline fun <R : Any> Routing.patch(crossinline body: suspend RoutingContext.(R) -> Unit): Routing

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

Builds a route to match PATCH requests with the specified path.

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

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

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

@JvmName(name = "patchTypedPath")
inline fun <R : Any> Routing.patch(path: Regex, crossinline body: suspend RoutingContext.(R) -> Unit): Routing

Builds a route to match PATCH requests with the specified regex path receiving a request body as content of the R type. Named parameters from regex can be accessed via ApplicationCall.parameters.

Link copied to clipboard
abstract fun <F : Any> plugin(plugin: Plugin<*, *, F>): F

Gets a plugin instance for this pipeline, or fails with MissingApplicationPluginException if the plugin is not installed.

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

Creates a route to match a request port.

Link copied to clipboard

Builds a route to match POST requests.

@JvmName(name = "postTyped")
inline fun <R : Any> Routing.post(crossinline body: suspend RoutingContext.(R) -> Unit): Routing

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

Builds a route to match POST requests with the specified path.

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

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

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

@JvmName(name = "postTypedPath")
inline fun <R : Any> Routing.post(path: Regex, crossinline body: suspend RoutingContext.(R) -> Unit): Routing

Builds a route to match POST requests with the specified regex path receiving a request body as content of the R type. Named parameters from regex can be accessed via ApplicationCall.parameters.

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

Support pre-compressed files and resources

Link copied to clipboard

Builds a route to match PUT requests.

@JvmName(name = "putTyped")
inline fun <R : Any> Routing.put(crossinline body: suspend RoutingContext.(R) -> Unit): Routing

Builds a route to match PUT requests receiving a request body as content of the R type.

Builds a route to match PUT requests with the specified path.

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

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

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

@JvmName(name = "putTypedPath")
inline fun <R : Any> Routing.put(path: Regex, crossinline body: suspend RoutingContext.(R) -> Unit): Routing

Builds a route to match PUT requests with the specified regex path receiving a request body as content of the R type. Named parameters from regex can be accessed via ApplicationCall.parameters.

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

Sets up routing to serve resource as remotePath in resourcePackage

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

Sets up routing to serve all resources in resourcePackage

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

Builds a route to match the specified path.

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.

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

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

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.

Link copied to clipboard
fun Routing.singlePageApplication(configBuilder: SPAConfig.() -> Unit = {})

Serves a single-page application. You can learn more from Serving single-page applications.

Link copied to clipboard
fun Routing.static(configure: Routing.() -> Unit): Routing

Create a block for static content

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

Create a block for static content at specified remotePath

Link copied to clipboard
fun Routing.staticFiles(remotePath: String, dir: File, index: String? = "index.html", block: StaticContentConfig<File>.() -> Unit = {}): Routing

Sets up RoutingRoot to serve static files. All files inside dir will be accessible recursively at "remotePath/path/to/file". If the requested file is a directory and index is not null, then response will be index file in the requested directory.

Link copied to clipboard
fun Routing.staticFileSystem(remotePath: String, basePath: String?, index: String? = "index.html", fileSystem: FileSystem = FileSystems.getDefault(), block: StaticContentConfig<Path>.() -> Unit = {}): Routing

Sets up RoutingRoot to serve fileSystem as static content. All paths inside basePath will be accessible recursively at "remotePath/path/to/resource". If requested path doesn't exist and index is not null, then response will be index path in the requested package.

Link copied to clipboard
fun Routing.staticResources(remotePath: String, basePackage: String?, index: String? = "index.html", block: StaticContentConfig<URL>.() -> Unit = {}): Routing

Sets up RoutingRoot to serve resources as static content. All resources inside basePackage will be accessible recursively at "remotePath/path/to/resource". If requested resource doesn't exist and index is not null, then response will be index resource in the requested package.

Link copied to clipboard
fun Routing.staticZip(remotePath: String, basePath: String?, zip: Path, index: String? = "index.html", block: StaticContentConfig<Path>.() -> Unit = {}): Routing

Sets up RoutingRoot to serve contents of zip as static content. All paths inside basePath will be accessible recursively at "remotePath/path/to/resource". If requested path doesn't exist and index is not null, then response will be index path in the requested package.

Link copied to clipboard
abstract fun trace(block: (RoutingResolveTrace) -> Unit)

Registers a function used to trace route resolution. Might be useful if you need to understand why a route isn't executed. To learn more, see Tracing routes.