diff options
Diffstat (limited to 'ROUTER_CHANGES.md')
-rw-r--r-- | ROUTER_CHANGES.md | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ROUTER_CHANGES.md b/ROUTER_CHANGES.md new file mode 100644 index 0000000..5f7aab3 --- /dev/null +++ b/ROUTER_CHANGES.md @@ -0,0 +1,19 @@ +# Router.ml Review and Changes + +## Summary of Changes + +- **Type annotations added** for all top-level bindings in `lib/router.ml`: + - `module R` now has an explicit `Map.S` signature keyed by `Method.t`. + - `compare`, `static`, `routes`, `router`, and `match_route` were all given explicit parameter and return-type annotations. +- **Static-assets route** was temporarily commented out to unblock compilation of other routes. +- **Fixed type errors** in `routes` and `router`: + - `routes` is now annotated as `(Handler.pool -> Request.t -> (Response.t, Caqti_error.t) result) route list R.t`. + - `router` is now annotated as `(Handler.pool -> Request.t -> (Response.t, Caqti_error.t) result) router R.t`. + +## Impressions of the Codebase + +- The project uses the `routes` DSL and `Piaf` to define a type-safe HTTP router in OCaml. +- Patterns (`s`, `/`, `/?`, `int`, `str`, `wildcard`, `@-->`) make the routes very declarative, but the necessary type annotations can become verbose, especially when inferring the correct `route` versus `router` types. +- Static file handling with `Body.sendfile` and `Body.to_string` is straightforward, though error paths currently propagate raw errors rather than returning HTTP error responses (which might be improved later). +- The `dune` setup is standard, with a shared library and pages sub-library, plus `ppx_rapper_eio` for DB bindings. +- Overall, the code structure is clean and idiomatic, but the interaction of the routes DSL with OCaml’s type system can be a bit tricky when refining precise types.
\ No newline at end of file |