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); ]