package webmachine

  1. Overview
  2. Docs

Description

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.

Published: 11 Dec 2018

README

ocaml-webmachine

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.

Installation

Install the library and its depenencies via OPAM:

opam install webmachine

Getting Started

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.

Examples

To build the examples in the examples/ subdirectory:

jbuilder build _build/default/examples/hello_lwt.exe
jbuilder build _build/default/examples/crud_lwt.exe
jbuilder build _build/default/examples/hello_async.exe

Development

To install development dependencies, pin the package from the root of the repository:

opam pin add -n webmachine .
opam install --deps-only webmachine

After this, you may install a development version of the library using the install command as usual.

For building and running the tests during development, you will need to install the oUnit package and run tests:

opam install oUnit
jbuilder runtest

License

BSD3, see LICENSE file for its text.

Dependencies (6)

  1. re >= "1.7.2"
  2. jbuilder >= "1.0+beta10"
  3. dispatch >= "0.3.0" & < "0.5.0"
  4. cohttp >= "1.0.0"
  5. ptime >= "0.8.0"
  6. ocaml >= "4.03.0"

Dev Dependencies (1)

  1. ounit with-test & >= "1.0.2"

Used by (2)

  1. irmin-http >= "2.0.0"
  2. session-webmachine

Conflicts

None