How to write a web server (service) in OCaml?
I wish to write a web service server (using http protocol) in OCaml.
For a simple example, I want to write a http server
. User can access it and provide parameter like http://myservice.com?i=1&j=2
. Then my server get the request and parameters and calculate i+j
and return the result.
Of course, my service will be more complicated for the calculation part. Instead of this simple example of calculation, what I really need to do is to
So, I also need to consider parallelism
/ multi-threading
, although I want to start with simple case first.
My questions are:
http server
? I have looked into Ocamlnet 3 and think it might be a good candidate, but it lacks good tutorial and I still don't know how to use nethttpd
or netplex
etc. parallelism
, then how can I make each service instance not blocking? Matias Giovannini has a good tutorial how to do this in ocamlnet:
http://alaska-kamtchatka.blogspot.ca/2012/10/how-to-write-simple-web-application.html
Personally I can't stand ocamlnet so I'd look into cohttp. Ocamlnet is bigger, more mature, and has more docs however.
我想你应该给Ocsigen一个尝试
链接地址: http://www.djcxy.com/p/79340.html上一篇: 如何让OCaml顶级使用电池?