Dear OCamlers,
I am pleased to announce v3.0.0 release of wtr (Well Typed Router)
. wtr
is a trie-based router for OCaml HTTP web applications.
v3.0.0 introduces a set of combinators(functions) for specifying routes/router. This is in addition to the ppx
mechanism which is now available in a separate package wtr-ppx
. Let me give you a small example of the new functionalities.
Let’s assume we want to match the following HTTP target/url:
/hello/true?i=233&s=str1
/hello/false?i=-1234&s=str2
This is how it can be implemented via the new combinators:
let target2 = Wtr.(exact "hello" / bool /? qint "i" / qstring "s" /?. ())
and correspondingly via the ppx:
let target2 = {%routes| /hello/:bool?i=:int&s=:string |} about_page
Other notable changes are:
- Addition of
pretty printers
of routes and router to aid in the debugging and usage inutop
- Massive overhaul of the documentation which include both the prose and the addition of examples/samples.
Enjoy!
Bikal