Closed rgrinberg closed 5 years ago
So does this mean Opium.App should become a functor with a Cohttp_lwt.Server
as parameter?
Hi @raboof, thanks for the interest. Looks like I've missed your first comment.
At first glance, yes, functorising over Cohttp_lwt would work. But it's a bit of a brute force approach. At the end of the day, an opium app is approximately Rock.Request.t -> Rock.Response.t
- none of that is unix dependent. So the same Opium_rock.App.t
should run on unix/mirage without modification in principle. Nevertheless, I've let some unix dependencies creep up:
Opium_rock.App.run
- is hard coded to use Unix.To address the points above we need to provide 2 opium entry modules
Opium_mirage.Std
- Mirage stuffOpium.Std
- Unix specific stuff.Opium_kernel.Std
as a base module (but I'm not sure yet).Opium_rock
will also need to be stripped of unixisms and extended by Opium_rock_unix
and Opium_rock_mirage
(providing the platform dependent run
function). After that it should be wrapped by the appropriate Opium*.Std
module as Rock
.
In summary, I don't see functors being necessary to do this separation. Most of the work will just be splitting modules and re-assembling them in the appropriate Std
modules.
Let me know if you have questions. This could be a lot to chew down if you haven't done much OCaml.
Would Opium_mirage.Std
contain anything Mirage-specific? If not, could we call that Opium.Std
('bring your own Cohttp_lwt.Server
'), and have an Opium_unix.Std
to make unix-specific things available?
@raboof I think it's sensible to include mirage dependent stuff there. I'd prefer if the base was Opium_kernel
though and leave Opium.Std
as unix. For the simple reason that the vast majority of users today only care about that.
OK, shifted things around a bit in #36 - I wasn't sure where to put start
and run_command
module-wise.
Closing this as opium_kernel doesn't have any unix dependancies, and i'm still focusing on just keeping Opium.Std
focussed on unix
+1 :)
I'd be willing to help but I'm afraid I'd require some hand-holding as I'm not too familiar with OCaml yet.