Skip to content

Commit 0f917dd

Browse files
committed
format
1 parent 03c3e09 commit 0f917dd

File tree

3 files changed

+39
-27
lines changed

3 files changed

+39
-27
lines changed

.ocamlformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = 0.26.2
1+
version = 0.27.0
22
profile=conventional
33
margin=80
44
if-then-else=k-r

src/core/route.ml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ let rec pp_ : type a b. Buffer.t -> (a, b) t -> unit =
7373
| Rest { url_encoded } ->
7474
bpf out "<rest_of_url%s>"
7575
(if url_encoded then
76-
"_urlencoded"
77-
else
78-
"")
76+
"_urlencoded"
77+
else
78+
"")
7979
| Compose (Exact s, tl) -> bpf out "%s/%a" s pp_ tl
8080
| Compose (Int, tl) -> bpf out "<int>/%a" pp_ tl
8181
| Compose (String, tl) -> bpf out "<str>/%a" pp_ tl
@@ -96,17 +96,29 @@ let rec to_url_rec : type b. Buffer.t -> (b, string) t -> b =
9696
fun buf route ->
9797
match route with
9898
| Fire -> Buffer.contents buf
99-
| Rest {url_encoded=_} ->
100-
(fun str -> Buffer.add_string buf str; Buffer.contents buf)
99+
| Rest { url_encoded = _ } ->
100+
fun str ->
101+
Buffer.add_string buf str;
102+
Buffer.contents buf
101103
| Compose (comp, rest) ->
102104
(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+
| Exact s ->
106+
Buffer.add_string buf s;
107+
Buffer.add_char buf '/';
108+
to_url_rec buf rest
109+
| Int ->
110+
fun i ->
111+
Printf.bprintf buf "%d/" i;
112+
to_url_rec buf rest
105113
| 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))
114+
fun s ->
115+
Printf.bprintf buf "%s/" s;
116+
to_url_rec buf rest
117+
| String_urlencoded ->
118+
fun s ->
119+
Printf.bprintf buf "%s/" (Util.percent_encode s);
120+
to_url_rec buf rest)
109121

110-
let to_url (h: ('a, string) t) : 'a =
122+
let to_url (h : ('a, string) t) : 'a =
111123
let buf = Buffer.create 16 in
112124
to_url_rec buf h

src/core/route.mli

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(** Routing
22
3-
Basic type-safe routing of handlers based on URL paths. This is optional,
4-
it is possible to only define the root handler with something like
5-
{{: https://github.com/anuragsoni/routes/} Routes}.
3+
Basic type-safe routing of handlers based on URL paths. This is optional, it
4+
is possible to only define the root handler with something like
5+
{{:https://github.com/anuragsoni/routes/} Routes}.
66
@since 0.6 *)
77

88
type ('a, 'b) comp
@@ -27,31 +27,31 @@ val return : ('a, 'a) t
2727
(** Matches the empty path. *)
2828

2929
val rest_of_path : (string -> 'a, 'a) t
30-
(** Matches a string, even containing ['/']. This will match
31-
the entirety of the remaining route.
32-
@since 0.7 *)
30+
(** Matches a string, even containing ['/']. This will match the entirety of the
31+
remaining route.
32+
@since 0.7 *)
3333

3434
val rest_of_path_urlencoded : (string -> 'a, 'a) t
35-
(** Matches a string, even containing ['/'], and URL-decode it (piecewise).
36-
This will match the entirety of the remaining route.
37-
@since 0.7 *)
35+
(** Matches a string, even containing ['/'], and URL-decode it (piecewise). This
36+
will match the entirety of the remaining route.
37+
@since 0.7 *)
3838

3939
val ( @/ ) : ('a, 'b) comp -> ('b, 'c) t -> ('a, 'c) t
40-
(** [comp / route] matches ["foo/bar/…"] iff [comp] matches ["foo"],
41-
and [route] matches ["bar/…"]. *)
40+
(** [comp / route] matches ["foo/bar/…"] iff [comp] matches ["foo"], and [route]
41+
matches ["bar/…"]. *)
4242

4343
val exact_path : string -> ('a, 'b) t -> ('a, 'b) t
4444
(** [exact_path "foo/bar/..." r] is equivalent to
45-
[exact "foo" @/ exact "bar" @/ ... @/ r]
46-
@since 0.11 **)
45+
[exact "foo" @/ exact "bar" @/ ... @/ r]
46+
@since 0.11 **)
4747

4848
val pp : Format.formatter -> _ t -> unit
4949
(** Print the route.
50-
@since 0.7 *)
50+
@since 0.7 *)
5151

5252
val to_string : _ t -> string
5353
(** Print the route.
54-
@since 0.7 *)
54+
@since 0.7 *)
5555

5656
val to_url : ('a, string) t -> 'a
5757

0 commit comments

Comments
 (0)