Internal: shared http/af stack for Dream (server) and Hyper (client)

Dream is one flat module in one package, documented on
one page, but with many examples. It offers:

...all without sacrificing ease of use — Dream has:

Every part of the API is arranged to be easy to understand, use, and remember.
Dream sticks to base OCaml types like string and list, introducing only a
few types of its own — and some of those are just abbreviations
for bare functions!

The neat interface is not a limitation. Everything is still configurable by a
large number of optional arguments, and very loose coupling. Where necessary,
Dream exposes the lower-level machinery that it is composed from. For example,
the basic body and WebSocket readers return strings, but you can
also do zero-copy streaming.

You can even run Dream as a quite bare abstraction over its underlying
set of HTTP libraries
, where it acts only as minimal glue code between
their slightly different interfaces.

And, even though Dream is presented as one package for ordinary usage, it is
internally factored into several sub-libraries, according to the
different dependencies of each, for fast porting to different environments.

Dream is a low-level and unopinionated framework, and you can swap out its
conveniences. For example, you can use TyXML with server-side JSX
instead of Dream's built-in templates. You can bundle assets into a single
Dream binary
, or use Dream in a subcommand. Dream tries to be as
functional as possible, touching global runtime state only lazily, when called

Quick start

This downloads and runs quickstart.sh, which does a
sandboxed build of one of the first tutorials,
2-middleware. It's mostly the same as:

git clone https://github.com/aantron/dream.git --recursive
cd dream/example/2-middleware
npm install esy && npx esy
npx esy start

Knowing that, you can start from any other example. All of them
include their own build commands. They don't have to be subdirectories of
dream — you can copy them out to start your own project directory.
Especially consider starting with the full-stack examples, which
build both a Dream server and a JavaScript client.


opam install dream.1.0.0~alpha2

After that, go to one of the examples, such as 1-hello, and
build it:

cd example/1-hello
dune exec --root . ./hello.exe


Most of the examples are loaded into the playground. For instance,
2-middleware is at


Recommended projects

Example repositories


Apart from the issues, good places
to discuss Dream are...

Highlight @antron to poke @aantron specifically.


All kinds of contributions are welcome, including examples, links to blogs,
related libraries, and, of course, PRs! See CONTRIBUTING.md.

As an immediate note, if you'd like to clone the repo, be sure to use
--recursive, because Dream uses several git submodules:

git clone https://github.com/aantron/dream.git --recursive


Dream is based on work by the authors and contributors of its many
and their transitive dependencies. There are, however,
several influences that cannot be discovered directly:

12 Feb 2022
Reverse Dependencies
>= "1.0.0~alpha3"