aboutsummaryrefslogtreecommitdiff
path: root/bin/main.ml
diff options
context:
space:
mode:
Diffstat (limited to 'bin/main.ml')
-rw-r--r--bin/main.ml20
1 files changed, 16 insertions, 4 deletions
diff --git a/bin/main.ml b/bin/main.ml
index 79593c9..1c1c442 100644
--- a/bin/main.ml
+++ b/bin/main.ml
@@ -1,5 +1,5 @@
(** Create the handler for the service *)
-let handler =
+let nbcar_handler =
Dream_handler.handle
(module Services_impl.Nb_car)
(fun (() : Services_impl.Nb_car.placeholders) body ->
@@ -10,12 +10,23 @@ let handler =
nbcar = Int64.of_int (String.length body.value);
})
+let capitalize_handler =
+ Dream_handler.handle
+ (module Services_impl.Capitalize)
+ (fun () body ->
+ Lwt.return_ok
+ Services_impl.Capitalize.{ value = String.uppercase_ascii body.value })
+
(* The handler and the route are not created at the same time because we may
want create a specific handler, for example one checking CRSF in the query
and can’t infer this from the service signature only *)
(** And create the route. *)
-let route = Dream_handler.register (module Services_impl.Nb_car) handler
+let nbcar_route =
+ Dream_handler.register (module Services_impl.Nb_car) nbcar_handler
+
+and capitalize_route =
+ Dream_handler.register (module Services_impl.Capitalize) capitalize_handler
(** Generate a default static page *)
let hello : Dream.handler =
@@ -32,7 +43,7 @@ let hello : Dream.handler =
<div class="level">
<div class="level-left">
<div class="level-item"><h1 class="title">
- Dashboard
+ Example
</h1></div>
</div>
<div class="level-right" style="display: none;">
@@ -76,7 +87,8 @@ let () =
Dream.get "/js/**" (Dream.static ~loader:js_assets "");
Dream.get "/css/**" (Dream.static ~loader:css_assets "");
Dream.get "/" hello;
- route;
+ nbcar_route;
+ capitalize_route;
]
(* Now test the application by connecting to