File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -91,3 +91,22 @@ module Private_ = struct
9191end
9292
9393let pp out x = Format. pp_print_string out (to_string x)
94+
95+ let rec to_url_rec : type b. Buffer.t -> (b, string) t -> b =
96+ fun buf route ->
97+ match route with
98+ | Fire -> Buffer. contents buf
99+ | Rest {url_encoded =_ } ->
100+ (fun str -> Buffer. add_string buf str; Buffer. contents buf)
101+ | Compose (comp , rest ) ->
102+ (match comp with
103+ | Exact s -> Buffer. add_string buf s; Buffer. add_char buf '/' ; to_url_rec buf rest
104+ | Int -> (fun i -> Printf. bprintf buf " %d/" i; to_url_rec buf rest)
105+ | String ->
106+ (fun s -> Printf. bprintf buf " %s/" s; to_url_rec buf rest)
107+ | String_urlencoded ->
108+ (fun s -> Printf. bprintf buf " %s/" (Util. percent_encode s); to_url_rec buf rest))
109+
110+ let to_url (h : ('a, string) t ) : 'a =
111+ let buf = Buffer. create 16 in
112+ to_url_rec buf h
Original file line number Diff line number Diff line change @@ -53,6 +53,8 @@ val to_string : _ t -> string
5353(* * Print the route.
5454 @since 0.7 *)
5555
56+ val to_url : ('a , string ) t -> 'a
57+
5658module Private_ : sig
5759 val eval : string list -> ('a , 'b ) t -> 'a -> 'b option
5860end
You can’t perform that action at this time.
0 commit comments