annotation class Resource(path: String)

An annotation for classes that act as typed routes. All annotated types should be Serializable.

Every property that has a corresponding placeholder inside path is used as a value for this placeholder. Other properties are put into the URL query. Example:

data class UserById(val id: Long, val properties: List<String>)

val userById = UserById(id = 123, properties = listOf("name", "avatar"))
val url = href(userById)

Properties can be primitives or types annotated with the Serializable annotation.

You can nest class for better organization, but all nested classes should have a property with an outer class type. Example:

data class Users {
data class ById(val parent: Users = Users(), val id: Long)

data class Add(val parent: Users = Users(), val name: String)
val userById = Users.ById(123)
val addUser = Users.add("new_name")


Link copied to clipboard
fun Resource(path: String)


Link copied to clipboard
val path: String

the route path, including the class property names wrapped with curly braces.