Resto: Add Resto.forge_partial_request

This commit is contained in:
Grégoire Henry 2018-02-11 19:17:39 +01:00
parent 0f0ec6ab7a
commit d78fa86372
2 changed files with 16 additions and 7 deletions

View File

@ -664,10 +664,10 @@ module MakeService(Encoding : ENCODING) = struct
} }
let forge_request_args let forge_request_args
: type p. (unit, p) path -> p -> string list : type pr p. (pr, p) path -> p -> string list
= fun path args -> = fun path args ->
let rec forge_request_args let rec forge_request_args
: type k. (unit, k) rpath -> k -> string list -> string list : type k. (pr, k) rpath -> k -> string list -> string list
= fun path args acc -> = fun path args acc ->
match path, args with match path, args with
| Root, _ -> | Root, _ ->
@ -711,9 +711,9 @@ module MakeService(Encoding : ENCODING) = struct
end in end in
loop fields loop fields
let forge_request let forge_partial_request
: type p i q o e. : type pr p i q o e.
(_, unit, p, q, i, o, e) service -> ?base:Uri.t -> p -> q -> i request (_, pr, p, q, i, o, e) service -> ?base:Uri.t -> p -> q -> i request
= fun s ?base:(uri = Uri.empty) args query -> = fun s ?base:(uri = Uri.empty) args query ->
let path = String.concat "/" (forge_request_args s.path args) in let path = String.concat "/" (forge_request_args s.path args) in
let prefix = Uri.path uri in let prefix = Uri.path uri in
@ -722,9 +722,14 @@ module MakeService(Encoding : ENCODING) = struct
let uri = Uri.with_query' uri (forge_request_query s.types.query query) in let uri = Uri.with_query' uri (forge_request_query s.types.query query) in
{ meth = s.meth ; uri ; input = s.types.input } { meth = s.meth ; uri ; input = s.types.input }
let forge_request = let forge_partial_request =
(forge_request (forge_partial_request
: (meth, _, _, _, _, _, _) service -> _ : (meth, _, _, _, _, _, _) service -> _
:> ([< meth], _, _, _, _, _, _) service -> _ ) :> ([< meth], _, _, _, _, _, _) service -> _ )
let forge_request =
(forge_partial_request
: (meth, _, _, _, _, _, _) service -> _
:> ([< meth], unit, _, _, _, _, _) service -> _ )
end end

View File

@ -363,6 +363,10 @@ module MakeService(Encoding : ENCODING) : sig
('meth, unit, 'params, 'query, 'input, 'output, 'error) service -> ('meth, unit, 'params, 'query, 'input, 'output, 'error) service ->
?base:Uri.t -> 'params -> 'query -> 'input request ?base:Uri.t -> 'params -> 'query -> 'input request
val forge_partial_request:
('meth, 'prefix, 'params, 'query, 'input, 'output, 'error) service ->
?base:Uri.t -> 'params -> 'query -> 'input request
module Internal : sig module Internal : sig
include (module type of (struct include Internal end)) include (module type of (struct include Internal end))