Resources

Adds support for type-safe routing using ResourcesCore.

Example:

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

  @Resource("/add")
  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

Functions

Link copied to clipboard
open override fun install(pipeline: Application, configure: Resources.Configuration.() -> Unit): Resources

Properties

Link copied to clipboard
open override val key: AttributeKey<Resources>