blob: 636ba64f79b9e5d607bad46ab230c2009ed166c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
val handle :
(module Services.JsonServerHandler
with type placeholders = 'placeholders
and type request = 'request
and type response = 'response) ->
('placeholders -> 'request -> ('response, string) Lwt_result.t) ->
'placeholders ->
Dream.handler
(** [handle (module S) f] create a handler for the requests.
@arg f is the function receiving the variable parts of the url, the body
(matching the type S.request), the request (in order to fetch the
parameters) and returning a content of type S.response.
The function does not read any parameters from the URI, as the body is
supposed having all the required informations.
*)
module MakeChecked (S : Services.JsonServerHandler) : sig
exception Invalid_method
(** Exception raised if the method does not allow body content *)
val handle :
(S.placeholders -> S.request -> (S.response, string) Lwt_result.t) ->
S.placeholders ->
Dream.handler
end
val register :
?path:'placeholders Path.t ->
(module Services.JsonServerHandler with type placeholders = 'placeholders) ->
('placeholders -> Dream.handler) ->
Dream.route
(** Register a handler as a route. The module gives all the required information
(path, methods…) we need, and the handler can be created using the function
`handle` just above.
{[
let handler =
Dream_handler.handle
(module Service)
(fun (_args : Service.parameters) (_body : Services.request) ->
Lwt.return_ok _)
let route = Route_builder.register (module Service) handler
]}*)
|