Thank you! At the moment I don’t have a good answer for introspecting all the routes, because they are static OCaml patterns, they don’t exist as first-class values. But, I can tell you that there must always be a single entry point for all the routes. So you can definitely add a CORS and other middleware to all routes. For example, if you wrote a filter cors
:
// Your 'real server'
let server = fun
| (`GET, ([] | [""])) => hello
| _ => notFound;
// Wrapped with a cors filter
let server = (meth, path) => cors @@ server @@ (meth, path);
// Run the wrapper server
let () = Server.serve(server);
In fact I am going to add a config system to ReWeb and put in place some default-configured security filters on all servers out of the box. The config will be overridable.