In a session module, I have a function with this signature:
val auth
: (Opium.Request.t -> Opium.Response.t Lwt.t) -> Opium.Request.t -> Opium.Response.t Lwt.t
And this is how I use it in my routes:
App.get "/the/route" @@ Session.auth (fun req -> … )