Package io.ktor.locations

Types

LocationAttributeRouteService

class LocationAttributeRouteService : LocationRouteService

Implements LocationRouteService by extracting routing information from a Location annotation.

LocationRouteService

interface LocationRouteService

Provides services for extracting routing information from a location class.

Locations

open class Locations

EXPERIMENTAL Ktor feature that allows to handle and construct routes in a typed way.

Annotations

KtorExperimentalLocationsAPI

annotation class KtorExperimentalLocationsAPI

API marked with this annotation is experimental and is not guaranteed to be stable.

Location

annotation class Location

Annotation for classes that will act as typed routes.

Exceptions

LocationRoutingException

class LocationRoutingException : Exception

Exception indicating that route parameters in curly brackets do not match class properties.

Properties

locations

val ApplicationCall.locations: Locations
val Application.locations: Locations

Gets the Application.locations feature

Functions

delete

fun <T : Any> Route.delete(
    body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit
): Route

Registers a typed handler body for a DELETE location defined by class T.

get

fun <T : Any> Route.get(
    body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit
): Route

Registers a typed handler body for a GET location defined by class T.

handle

fun <T : Any> Route.handle(
    body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit
): Unit

Registers a handler body for a location defined by class T.

fun <T : Any> Route.handle(
    dataClass: KClass<T>,
    body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit
): Unit

Registers a handler body for a location defined by class dataClass.

head

fun <T : Any> Route.head(
    body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit
): Route

Registers a typed handler body for a HEAD location defined by class T.

href

fun PipelineContext<Unit, ApplicationCall>.href(
    location: Any
): String

Renders link to a location using current installed locations service

location

fun <T : Any> Route.location(body: Route.() -> Unit): Route

Registers a route body for a location defined by class T.

fun <T : Any> Route.location(
    data: KClass<T>,
    body: Route.() -> Unit
): Route

Registers a route body for a location defined by class data.

options

fun <T : Any> Route.options(
    body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit
): Route

Registers a typed handler body for a OPTIONS location defined by class T.

patch

fun <T : Any> Route.patch(
    body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit
): Route

Registers a typed handler body for a PATCH location defined by class T.

post

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

Registers a typed handler body for a POST location defined by class T.

put

fun <T : Any> Route.put(
    body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit
): Route

Registers a typed handler body for a PUT location defined by class T.

url

fun ApplicationCall.url(
    location: Any,
    block: URLBuilder.() -> Unit = {}
): String

Constructs a String with the url of a instance location whose class must be annotated with Location.