summaryrefslogtreecommitdiff
path: root/bs5/server/api/json.ml
diff options
context:
space:
mode:
Diffstat (limited to 'bs5/server/api/json.ml')
-rw-r--r--bs5/server/api/json.ml13
1 files changed, 13 insertions, 0 deletions
diff --git a/bs5/server/api/json.ml b/bs5/server/api/json.ml
new file mode 100644
index 0000000..3e4c68c
--- /dev/null
+++ b/bs5/server/api/json.ml
@@ -0,0 +1,13 @@
+open Ppx_yojson_conv_lib.Yojson_conv.Primitives
+
+type message_object = { message : string } [@@deriving yojson]
+
+let routes =
+ [
+ Dream.post "/json" (fun req ->
+ let%lwt body = Dream.body req in
+ let message_object =
+ body |> Yojson.Safe.from_string |> message_object_of_yojson
+ in
+ `String message_object.message |> Yojson.Safe.to_string |> Dream.json);
+ ]