Resources

object Resources

Adds support for type-safe routing using ResourcesCore.

Example:

@Serializable
@Resource("/users")
data class Users {
@Serializable
@Resource("/{id}")
data class ById(val parent: Users = Users(), val id: Long)

@Serializable
@Resource("/add")
data class Add(val parent: Users = Users(), val name: String)
}

routing {
get<Users.ById> { userById ->
val userId: Long = userById.id
}
post<Users.Add> { addUser ->
val userName: String = addUser.name
}
}

// client-side
val newUserId = client.post(Users.Add("new_user"))
val addedUser = client.get(Users.ById(newUserId))

Server: Type-safe routing

Client: Type-safe requests

See also

Resource

Functions

Link copied to clipboard
open fun install(pipeline: <ERROR CLASS>, configure: <ERROR CLASS>.() -> Unit): <ERROR CLASS>

Properties

Link copied to clipboard
open val key: <ERROR CLASS><<ERROR CLASS>>