diff options
Diffstat (limited to 'litedb/router.ml')
-rw-r--r-- | litedb/router.ml | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/litedb/router.ml b/litedb/router.ml index ef9d5c5..06dec3c 100644 --- a/litedb/router.ml +++ b/litedb/router.ml @@ -1,7 +1,9 @@ (* Import the StdLabels module which provides labeled versions of standard library functions *) open StdLabels + (* Import the Routes library for type-safe HTTP routing *) open Routes + (* Import Piaf for HTTP types like Method.t *) open Piaf @@ -25,9 +27,8 @@ module R = Map.Make (struct let routes = (* Use fold_left to build up a map of routes *) List.fold_left - (* For each (verb, route) pair, add the route to the map under that verb *) - ~f:(fun acc (v, r) -> R.add_to_list v r acc) - (* Start with an empty map *) + (* For each (verb, route) pair, add the route to the map under that verb *) + ~f:(fun acc (v, r) -> R.add_to_list v r acc) (* Start with an empty map *) ~init:R.empty (* List of (HTTP method, route pattern -> handler) tuples *) [ `GET, (s "posts" /? nil) @--> Handler.get_posts @@ -41,7 +42,7 @@ let routes = (* / int - captures an integer parameter (post ID) *) ; `GET, (s "comments" / int /? nil) @--> Handler.get_comment (* Get a single comment by ID *) - ; `GET, (s "users" / str / s "comments" /? nil) @--> Handler.get_user_comments + ; `GET, (s "users" / str / s "comments" /? nil) @--> Handler.get_user_comments (* / str - captures a string parameter (username) *) ; `GET, (s "posts" / int / s "comments" /? nil) @--> Handler.get_post_comments (* Get all comments for a specific post *) |