Something went wrong. Try again.
Share your Ktor endpoints between client and server spine.opensavvy.dev
rest http ktor kotlin arrow
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637package opensavvy.spine.api
/** * A resolved [Endpoint][AnyEndpoint]. * * The [AnyEndpoint] interface represents the _declaration_ of an endpoint. * For example, `GET /api/users/{user}` is not a 'real' endpoint: each user has its own endpoint. * This class, [ResolvedEndpoint], represents 'real' endpoints: `GET /api/users/111` and `GET /api/users/222` are possible * values of this class. * * To resolve an endpoint, start by [resolving its resource][ResolvedResource] then follow with the endpoint: * ```kotlin * println(Root / Users / User("999") / User.get) * ``` */class ResolvedEndpoint<E : AnyEndpoint> internal constructor( val resource: Resource, val data: E, override val path: Path,) : Addressed
/** * Resolves an [endpoint] declared in a resolved resource. * * ### Example * * ```kotlin * println(Root / Users / User("999") / User.get) * ``` */operator fun <R : Resource, Endpoint : AnyEndpoint> ResolvedResource<R>.div(endpoint: Endpoint) = ResolvedEndpoint( resource, endpoint, if (endpoint.path == null) path else path + endpoint.path!!)