This example shows the simplest Dream program one could write:
let () =
Dream.run(_ =>
Dream.html("Good morning, reasonable world!"));$ cd example/r-hello
$ npm install esy && npx esy
$ npx esy start
08.04.21 13:55:56.552 Running at http://localhost:8080
08.04.21 13:55:56.553 Type Ctrl+C to stop
After starting it, visit http://localhost:8080, and it will respond with its friendly greeting!
Note that we had to make an addition to
esy.json:
"dependencies": {
"@opam/reason": "^3.0.0"
}
See also:
r-templateshows templates with Reason syntax.2-middlewareintroduces the logger, the most commonly used Dream middleware. The example is in OCaml syntax.