Package io.ktor.server.locations

Types

Link copied to clipboard
annotation class KtorExperimentalLocationsAPI

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

Link copied to clipboard
annotation class Location(path: String)

Annotation for classes that will act as typed routes.

Link copied to clipboard
class LocationAttributeRouteService : LocationRouteService

Implements LocationRouteService by extracting routing information from a Location annotation.

Link copied to clipboard
data class LocationInfo

A location class/object registration info.

Link copied to clipboard
abstract class LocationPropertyInfo

Represents a location's property

Link copied to clipboard
interface LocationRouteService

Provides services for extracting routing information from a location class.

Link copied to clipboard
class LocationRoutingException(message: String) : Exception

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

Link copied to clipboard
open class Locations(application: Application, routeService: LocationRouteService)

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

Functions

Link copied to clipboard
inline fun <T : Any> Route.delete(noinline body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit): Route

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

Link copied to clipboard
inline fun <T : Any> Route.get(noinline body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit): Route

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

Link copied to clipboard
inline fun <T : Any> Route.handle(noinline body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit)

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

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

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

Link copied to clipboard
inline fun <T : Any> Route.head(noinline body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit): Route

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

Link copied to clipboard
fun PipelineContext<Unit, ApplicationCall>.href(location: Any): String

Renders link to a location using current installed locations service

Link copied to clipboard
inline fun <T : Any> ApplicationCall.location(): T

Retrieves the current call's location or fails if it is not available (request is not handled by a location class), or not yet available (invoked too early before the locations plugin takes place).

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

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

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

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

Link copied to clipboard
inline fun <T : Any> ApplicationCall.locationOrNull(): T

Retrieves the current call's location or fails if it is not available (request is not handled by a location class), or not yet available (invoked too early before the locations plugin takes place).

Link copied to clipboard
inline fun <T : Any> Route.options(noinline body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit): Route

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

Link copied to clipboard
inline fun <T : Any> Route.patch(noinline body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit): Route

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

Link copied to clipboard
inline fun <T : Any> Route.post(noinline body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit): Route

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

Link copied to clipboard
inline fun <T : Any> Route.put(noinline body: suspend PipelineContext<Unit, ApplicationCall>.(T) -> Unit): Route

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

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

Properties

Link copied to clipboard
val PipelineContext<Unit, ApplicationCall>.locations: Locations

Gets the Application.locations plugin

Link copied to clipboard
val ApplicationCall.locations: Locations

Gets the Application.locations plugin

Link copied to clipboard
val Application.locations: Locations

Gets the Application.locations plugin