ocaml-webmachine is a layer on top of cohttp that implements a state-machine-based HTTP request processor. It's particularly well-suited for writing RESTful APIs. As the name suggests, this is an OCaml port of the webmachine project.
Install the library and its depenencies via OPAM:
opam install webmachine
To install development versions of the library, pin the package from the root of the repository:
opam pin add .
You can install the latest changes by commiting them to the local git repository and running:
opam upgrade webmachine
For building and running the tests during development, you will need to install
the oUnit
package and reconfigure the build process to enable tests:
opam install oUnit
./configure --enable-tests
make && make test
webmachine implements this decision diagram to determine how an HTTP
request should be handled. This includes validation, authentication, content
negotiation, and caching. A resource specifies the decision that should be made
at each node in the diagram by defining the appropriate method in a resource
subclass. The correspondence is suggested by the name of the method for now.
This will be better-documented in the future.
To build the examples in the examples/
subdirectory, reconfigure the build
process and recompile:
./configure --enable-examples
make clean && make
BSD3, see LICENSE file for its text.