ocaml-cohttp
ocaml-cohttp copied to clipboard
cohttp 4 API questions
I tried to migrate the caldav (https://github.com/roburio/caldav) unikernel to cohttp 4.x, and so far failed. Would anyone be able to help me out?
In src/webdav_server, we define a functor Make
that takes a Cohttp_lwt.S.Server
. Earlier (in cohttp 2.x, conduit <=2.2) we passed in mirage/unikernel.ml the S : Cohttp_lwt.S.Server
along to the webdav_server. Now, the mirage cohttp_server
provides us with a Cohttp_mirage.Server.S
- that is not compatible with Cohttp_lwt.S.Server
.
Taking this as an example (I have more unikernels where I struggle with the update), how can I write a backend-agnostic (Lwt_unix / Mirage) web server library these days? Of course I could change the webdav_server implementation to take a Cohttp_mirage.Server.S
, but that increases the dependency cone of Unix-only (and testing) applications.
It looks like #742 is related, any hints? Some struggle is because in cohttp-mirage in server.ml the S
redefines the callback
. Why is this done?
//cc @samoht
//cc also @dinosaure
a solution for this is to explicitly define my own module type in caldav, as done in the referenced commit above. not a nice solution, but at least something that unblocks my updates.
I'm not too familiar with how web servers are written in mirage these days, but I'd imagine that your entire web server can be represented as (Request.t * Body.t) -> (Response.t * Body.t) Lwt.t
. If that's the case, isn't it just a matter of providing this callback to the individual server backends?
I moved on, and have no further interest in this issue. It also seems that cohttp is moving elsewhere, so I'll close this issue. Thanks for your replies and your work.