-
Notifications
You must be signed in to change notification settings - Fork 43
Basic Routing
Wicpar edited this page Dec 3, 2019
·
2 revisions
Basic routing happens like the Locations api from Ktor.
@Response("A String Response")
data class StringResponse(val str: String)
inside the apiRouting
as described in Setup
get<Unit, StringResponse> {
respond(StringResponse("Hello World"))
}
@Response("A String Response")
data class StringResponse(val str: String)
@Path("string/{a}") // `@Path` works like the ktor Locations api `@Location`, if it is declared in a route, it will append the path to the one in the context
data class StringParam(
@PathParam("A simple String Param") val a: String,
@QueryParam("Optional String") val optional: String? // Nullable Types are optional
)
get<StringParam, StringResponse> { params ->
respond(StringResponse(params.a))
}