-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.ml
More file actions
22 lines (20 loc) · 852 Bytes
/
Copy pathclient.ml
File metadata and controls
22 lines (20 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
let get_state_by_id_request room_id =
let url = "localhost:3000/get/" ^ room_id in
match Curly.(run (Request.make ~url ~meth:`GET ())) with
| Ok x -> x.Curly.Response.body
| Error e -> failwith ("error finding a room name: " ^ room_id)
let create_room_request room_id =
let url = "localhost:3000/post/room" in
let body =
{|{"room_id": |} ^ "\"" ^ room_id ^ "\"" ^ {|, "state_fen": |}
^ "\"" ^ State.init_fen () ^ "\"}"
in
match Curly.(run (Request.make ~body ~url ~meth:`POST ())) with
| Ok x -> x.Curly.Response.body
| Error e -> failwith "error making a room"
let update_room_state room_id state_fen =
let url = "localhost:3000/put/" ^ room_id in
let body = state_fen in
match Curly.(run (Request.make ~body ~url ~meth:`PUT ())) with
| Ok x -> x.Curly.Response.body
| Error e -> failwith "error updating room"