Skip to content

Multiplatform Ktor schema declarationopensavvy.spine.apiRootResource

RootResource

abstract class RootResource(slug: String) : Resource, Addressed

The root resource of an API.

The root resource is a special kind of StaticResource that doesn't have a parent.

It is expected that users of the library use this class to define the root of their API:

object Api : RootResource("v1") {
    object Users : StaticResource<Api>("/users", parent = Api)
    object Posts : StaticResource<Api>("/posts", parent = Api)
}

Constructors

RootResource

constructor(slug: String)

Creates a new RootResource. The passed slug should be used to differentiate between multiple APIs deployed on the same server. For example, "v1" and "v2". To select the exact URL used by the server, client should use the DefaultRequest plugin to specify a base URL.

Properties

children

Returns resources that are direct children of the current resource.

directEndpoints

Returns all endpoints that are declared on this resource.

endpoints

Returns all endpoints that are declared on this resource or any of its children.

fullSlug

The complete URL of this resource, starting from the RootResource, to this resource.

hierarchy

Returns the hierarchy of this resource: following the parent chain.

parent

override val parent: Nothing?

The parent of this resource. Since RootResource cannot have a parent, always returns null.

path

open override val path: Path

slug

val slug: String

The URL segment relating to this specific resource.