Multiplatform Ktor schema declaration • opensavvy.spine.api • ResolvedResource
ResolvedResource¶
class ResolvedResource<R : Resource> : Addressed
A resolved Resource.
The Resource class represents the declaration of a resource. For example, the /api/users/{user} is not a 'real' resource. This class, ResolvedResource, represents 'real' resources: '/api/users/111' and '/api/users/222' are possible values of this class.
To instantiate this class, specify the full path from the root, adding necessary runtime information where necessary. For example:
object Root : RootResource("api") {
object Users : StaticResource<Root>("users", Root) {
object User : DynamicResource<Users>("user", User)
}
}
// The root can be resolved with no further information, since it must be static:
println(Root.resolved)
// Static routes can be resolved simply by specifying their path:
println(Root / Users)
// Dynamic routes require specifying the dynamic segment during resolution:
println(Root / Users / User("123456789"))
Properties¶
path¶
resource¶
Functions¶
div¶
operator fun <R : Resource, Endpoint : AnyEndpoint> ResolvedResource<R>.div(endpoint: Endpoint): ResolvedEndpoint<Endpoint>
Resolves an endpoint declared in a resolved resource.
operator fun <Current : Resource, Child : StaticResource<Current>> ResolvedResource<Current>.div(child: Child): ResolvedResource<Child>
Resolves the static child resource under this ResolvedResource.
operator fun <Current : Resource, Child : DynamicResource<Current>> ResolvedResource<Current>.div(child: DynamicResource.Identified<Current, Child>): ResolvedResource<Child>
Resolves the dynamic child resource under this ResolvedResource by binding its identifier.