Skip to content

Commit 030b77e

Browse files
committed
more fix to examples
1 parent 30f7743 commit 030b77e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,23 +164,21 @@ module Api = struct
164164
| List_users : user list t [@GET "/"]
165165
| Create_user : user t [@POST "/"]
166166
| Get_user : { id : int } -> user t [@GET "/:id"]
167-
| Raw : Dream.response t [@GET "/raw"]
167+
| Raw : Ppx_deriving_router_runtime.response t [@GET "/raw"]
168168
[@@deriving router]
169169
end
170170
```
171171

172172
Then handler can be defined as follows:
173173
```ocaml
174-
let return = Ppx_deriving_router_runtime.Return.return
175-
176174
let api_handle : Dream.handler =
177175
let f : type a. a Api.t -> Dream.request -> a Lwt.t =
178176
fun x _req ->
179177
match x with
180-
| List_users -> return []
181-
| Create_user -> return { Api.id = 42 }
182-
| Get_user { id } -> return { Api.id }
183-
| Raw -> return (Dream.response "RAW")
178+
| List_users -> Lwt.return []
179+
| Create_user -> Lwt.return { Api.id = 42 }
180+
| Get_user { id } -> Lwt.return { Api.id }
181+
| Raw -> Dream.respond "RAW"
184182
in
185183
Api.handle { f }
186184
```
@@ -199,6 +197,7 @@ It is possible to designate a route parameter to be a request body, in this
199197
case, its value is decoded from the request body as JSON. The JSON decoder is
200198
generated automatically for the route parameter type:
201199
```ocaml
200+
open Ppx_deriving_json_runtime.Primitives
202201
type user_spec = { name : string } [@@deriving json]
203202
type _ api =
204203
| Create_user : {spec: user_spec; [@body]} -> int t [@POST]

0 commit comments

Comments
 (0)