Skip to content

Server-side typesafe Spine schema usageopensavvy.spine.serverTypedResponseScopeidOf

idOf

open fun idOf(resource: DynamicResource<*>): String

Extracts the identifier for a DynamicResource as it was provided by the client.

For example, if we declare the following API:

object Api : RootResource("api") {
    object Users : StaticResource<Api>("users", Api) {
        object User : DynamicResource<Users>("user", Users) {
            val get by get()
        }
    }
}

and the client calls the endpoint GET /api/users/123, then we can declare our route as:

route(Api.Users.User) {
    val id = idOf(Api.Users.User) // "123", because this is what the client passed for this path parameter
}