Resources

object Resources : HttpClientPlugin<Resources.Configuration, Resources>

Adds support for type-safe requests 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)
}

// client-side
val newUserId = client.post(Users.Add("new_user")) // "/users?name=new_user"
val addedUser = client.get(Users.ById(newUserId)) // "/user/123"

See also

Functions

Link copied to clipboard
open override fun install(plugin: Resources, scope: HttpClient)
Link copied to clipboard
open override fun prepare(block: Resources.Configuration.() -> Unit): Resources

Properties

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