Library
Module
Module type
Parameter
Class
Class type
module Encoding : Resto.ENCODING
module Service : module type of struct include Resto.MakeService(Encoding) end
type step =
| Static of string
A literal chunk
*)| Dynamic of Resto.Arg.descr
A chunk which describes a argument to a service
*)| DynamicTail of Resto.Arg.descr
The remainder of the chunks are to be interpreted as a list of arguments
*)The different chunks of a path
E.g., /archive/<year>/<months>/
has a Static "archive"
step followed by a Dynamic _
step followed by a Dynamic _
step. Each Dynamic _
step has an Resto.Arg
payload describing the chunk.
type conflict =
| CService of Resto.meth
| CDir
| CBuilder
| CTail
| CTypes of Resto.Arg.descr * Resto.Arg.descr
| CType of Resto.Arg.descr * string list
Possible error while registring services.
type ('query, 'input, 'output, 'error) types = {
query : 'query Resto.Query.t;
input : 'input Service.input;
output : 'output Encoding.t;
error : 'error Encoding.t;
}
type 'prefix directory = 'prefix t
type lookup_error = [
| `Not_found
| `Method_not_allowed of Resto.meth list
| `Cannot_parse_path of string list * Resto.Arg.descr * string
]
val lookup :
'prefix directory ->
'prefix ->
Resto.meth ->
string list ->
(registered_service, [> lookup_error ]) result Lwt.t
lookup d m p
is Ok (Service _)
if there is a service s
registered in d
and both the method of s
is m
and the path of s
matches p
. It is Error _
otherwise.
If it is Ok (Service _)
then the returned value corresponds to the registered service.
val allowed_methods :
'prefix directory ->
'prefix ->
string list ->
(Resto.meth list, [> lookup_error ]) result Lwt.t
allowed_methods d p
is the set of methods m
such that lookup d m p
is Ok _
. In other words, it is the set of methods m
such that a service has been registered in d
for a path that matches p
.
val empty : 'prefix directory
Empty tree
val prefix : ('pr, 'p) Resto.Path.path -> 'p directory -> 'pr directory
prefix p d
is a directory of services which includes a service registered on the path p / q
for each service registered on the path q
in d
.
merge d1 d2
is a directory which includes all the services of d1
and d2
.
val register :
'prefix directory ->
('meth, 'prefix, 'params, 'query, 'input, 'output, 'error) Service.t ->
('params -> 'query -> 'input -> [< ('output, 'error) Answer.t ] Lwt.t) ->
'prefix directory
register d s h
is a directory that contains all the services registered in d
plus the service s
. Requests to the service s
are handled by the handler h
.
val register0 :
unit directory ->
('m, unit, unit, 'q, 'i, 'o, 'e) Service.t ->
('q -> 'i -> [< ('o, 'e) Answer.t ] Lwt.t) ->
unit directory
Registring handler in service tree. Curryfied variant.
val register_dynamic_directory :
?descr:string ->
'prefix directory ->
('prefix, 'a) Resto.Path.path ->
('a -> 'a directory Lwt.t) ->
'prefix directory
Registring dynamic subtree.
val register_dynamic_directory1 :
?descr:string ->
'prefix directory ->
('prefix, unit * 'a) Resto.Path.path ->
('a -> (unit * 'a) directory Lwt.t) ->
'prefix directory
Registring dynamic subtree. (Curryfied variant)
val register_dynamic_directory2 :
?descr:string ->
'prefix directory ->
('prefix, (unit * 'a) * 'b) Resto.Path.path ->
('a -> 'b -> ((unit * 'a) * 'b) directory Lwt.t) ->
'prefix directory
val register_dynamic_directory3 :
?descr:string ->
'prefix directory ->
('prefix, ((unit * 'a) * 'b) * 'c) Resto.Path.path ->
('a -> 'b -> 'c -> (((unit * 'a) * 'b) * 'c) directory Lwt.t) ->
'prefix directory
val register_describe_directory_service :
'prefix directory ->
('prefix, 'prefix, 'error) Service.description_service ->
'prefix directory
Registring a description service.
val describe_directory :
recurse:bool ->
?arg:'a ->
'a directory ->
Encoding.schema Resto.Description.directory Lwt.t