Skip to content

Commit 5ecf4af

Browse files
committed
runtime: url query enc/dec for float
1 parent 0e8383b commit 5ecf4af

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

native/runtime/ppx_deriving_router_primitives.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ let string_of_url_query k xs =
2121
| None -> Error "missing value"
2222
| Some x -> Ok x)
2323

24+
let float_to_url_query k x = [ k, string_of_float x ]
25+
26+
let float_of_url_query k xs =
27+
last_wins k xs (function
28+
| None -> Error "missing value"
29+
| Some x -> (
30+
match float_of_string_opt x with
31+
| None -> Error "not a float value"
32+
| Some x -> Ok x))
33+
2434
let int_to_url_query k x = [ k, string_of_int x ]
2535

2636
let int_of_url_query k xs =

0 commit comments

Comments
 (0)