package yurt

  1. Overview
  2. Docs

Source file yurt_client.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
open Lwt.Infix
open Cohttp_lwt_unix

let get ?ctx ?headers url =
    Client.get ?ctx ?headers (Uri.of_string url) >>= fun (res, body) ->
        Cohttp_lwt.Body.to_string body >|= fun body_string ->
            res, body_string

let post ?ctx ?headers ?body url =
    Client.post ?ctx ?headers ?body (Uri.of_string url) >>= fun (res, body) ->
        Cohttp_lwt.Body.to_string body >|= fun body_string ->
            res, body_string

let post_form ?ctx ?headers ~params url =
    Client.post_form ?ctx ?headers ~params (Uri.of_string url) >>= fun (res, body) ->
        Cohttp_lwt.Body.to_string body >|= fun body_string ->
            res, body_string

let request ?ctx ?headers ?body meth url =
    Client.call ?ctx ?headers ?body meth (Uri.of_string url) >>= fun (res, body) ->
        Cohttp_lwt.Body.to_string body >|= fun body_string ->
            res, body_string

let get_json ?ctx ?headers url =
    get ?ctx ?headers url >|= fun (r, b) ->
        r, Ezjsonm.from_string b

let post_json ?ctx ?headers ?body url =
    post ?ctx ?headers ?body url >|= fun (r, b) ->
        r, Ezjsonm.from_string b

let post_form_json ?ctx ?headers ?params:(params=[]) url =
    post_form ?ctx ?headers ~params url >|= fun (r, b) ->
        r, Ezjsonm.from_string b