-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_http_client.mli
107 lines (97 loc) · 2.75 KB
/
util_http_client.mli
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
val trace : bool ref
(** Log all requests and responses (default: false) *)
type response =
(Cohttp.Code.status_code * (string * string) list * string)
val wrap :
?headers:(string * string) list ->
?body:string ->
Cohttp.Code.meth ->
Uri.t -> response Lwt.t
val get :
?headers:(string * string) list ->
Uri.t -> response Lwt.t
val post :
?headers:(string * string) list ->
?body:string ->
Uri.t -> response Lwt.t
val head :
?headers:(string * string) list ->
Uri.t -> response Lwt.t
val delete :
?headers:(string * string) list ->
?body:string ->
Uri.t -> response Lwt.t
val put :
?headers:(string * string) list ->
?body:string ->
Uri.t -> response Lwt.t
val patch :
?headers:(string * string) list ->
?body:string ->
Uri.t -> response Lwt.t
val post_form: Uri.t -> (string * string) list -> response Lwt.t
val post_form': Uri.t -> (string * string list) list -> response Lwt.t
(* (string * string) list is more convenient, while
(string * string list) list is provided for compatibility with `Uri`. *)
module type Wrapped = sig
type result
val get :
?headers:(string * string) list ->
Uri.t -> result Lwt.t
val post :
?headers:(string * string) list ->
?body:string ->
Uri.t -> result Lwt.t
val head :
?headers:(string * string) list ->
Uri.t -> result Lwt.t
val delete :
?headers:(string * string) list ->
?body:string ->
Uri.t -> result Lwt.t
val put :
?headers:(string * string) list ->
?body:string ->
Uri.t -> result Lwt.t
val patch :
?headers:(string * string) list ->
?body:string ->
Uri.t -> result Lwt.t
end
module Original : Wrapped with type result = response
module type Wrapper = sig
type orig_result
type result
val wrap : (unit -> orig_result Lwt.t) -> result Lwt.t
end
module Wrap
(U: Wrapped)
(W: Wrapper with type orig_result = U.result):
Wrapped with type result = W.result
(** Module matching the signature expected by elasticsearch:
the URI is a string and the response status is an int. *)
module Elasticsearch_lwt :
sig
type uri = string
type response = (int * (string * string) list * string)
type 'a computation = 'a Lwt.t
val bind : 'a computation -> ('a -> 'b computation) -> 'b computation
val return : 'a -> 'a computation
val head :
?headers:(string * string) list ->
uri -> response option computation
val get :
?headers:(string * string) list ->
uri -> response option computation
val post :
?headers:(string * string) list ->
?body:string ->
uri -> response option computation
val delete :
?headers:(string * string) list ->
uri -> response option computation
val put :
?headers:(string * string) list ->
?body:string ->
uri -> response option computation
end