Dream

整洁、功能完备的 Web 框架。「Tidy, feature-complete Web framework」

Github星跟踪图

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:

  • A simple programming model — Web apps are just functions!
  • Composable middleware and routes.
  • Unified, internationalization-friendly error handling.
  • Cryptography helpers, key rotation, and a chosen cipher.
  • A neat logger, and attention to configuring the OCaml runtime
    nicely.
  • Deployment instructions for Digital Ocean, Heroku, and
    Fly.io, with sample CI scripts.

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
into.

Quick start

Visit one of the first tutorials in the online
playground
, and read its
docs.
You can get and build it locally with:

Most of the other examples are also loaded in the playground. See
the links on its home page.

esy

Visit any of the examples, such as
2-middleware, and re-create the files locally. The file
esy.json
shows how to depend on Dream. All of the examples are installed by running npx esy, and started with npx esy start.

opam

opam install dream

After that, go to any of the examples, such as
2-middleware, re-create the files locally, and run it:

dune exec ./middleware.exe

Documentation

Example repositories

Contact

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

Highlight @antron to poke @aantron specifically.

Contributing

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

Acknowledgements

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

主要指标

概览
名称与所有者aantron/dream
主编程语言OCaml
编程语言Makefile (语言数: 11)
平台
许可证MIT License
所有者活动
创建于2021-03-08 02:59:36
推送于2024-12-20 08:18:22
最后一次提交2024-12-20 11:18:22
发布数8
最新版本名称1.0.0-alpha8 (发布于 2024-12-01 20:24:24)
第一版名称1.0.0-alpha1 (发布于 2021-04-20 14:23:25)
用户参与
星数1.7k
关注者数26
派生数147
提交数1k
已启用问题?
问题数238
打开的问题数102
拉请求数119
打开的拉请求数22
关闭的拉请求数20
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?