Module type Rest.CONTROLLER

A module of type CONTROLLER can be used to create a resource with resource_of_controller. Use a controller instead of a service and a view if you need low level control.

type t

t is the type of the resource.

val index : string -> Rock.Request.t -> Rock.Response.t Lwt.t

index name request returns a list of all resource instances as a response.

name is the name of the resource in plural, for example orders or users.

val new' : ?⁠key:string -> string -> Rock.Request.t -> Rock.Response.t Lwt.t

new' ?key name request returns a form to create instances of the resource as a response.

name is the name of the resource in plural, for example orders or users.

The form data is stored in the flash storage under the key. By default, the value is _form.

val create : string -> ('a'bt) Conformist.t -> Rock.Request.t -> Rock.Response.t Lwt.t

create name schema request handles the creation of new resource instances and returns the creation result as a response.

name is the name of the resource in plural, for example orders or users.

val show : string -> Rock.Request.t -> Rock.Response.t Lwt.t

show name request returns a single resource instance as a response.

name is the name of the resource in plural, for example orders or users.

val edit : ?⁠key:string -> string -> Rock.Request.t -> Rock.Response.t Lwt.t

edit ?key name request returns a form to edit resource instances as a response.

name is the name of the resource in plural, for example orders or users.

The form data is stored in the flash storage under the key. By default, the value is _form.

val update : string -> ('a'bt) Conformist.t -> Rock.Request.t -> Rock.Response.t Lwt.t

update name schema request handles the update of a resource instance and returns the update result as a response.

name is the name of the resource in plural, for example orders or users.

val delete' : string -> Rock.Request.t -> Rock.Response.t Lwt.t

delete name request handles the deletion of a resource instance and returns the deletion result as a response.

name is the name of the resource in plural, for example orders or users.