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))
Content copied to clipboard
Server: Type-safe routing
Client: Type-safe requests