mirror of
https://github.com/aantron/dream.git
synced 2025-12-30 00:26:32 -05:00
Document example/r-hello
This commit is contained in:
parent
61925d1929
commit
bad00e4301
11
README.md
11
README.md
@ -89,15 +89,16 @@ installed in your switch, you may have to remove them with `opam remove` to
|
||||
avoid conflicts. However, they should not be pulled into a basic build of Dream
|
||||
and most programs that use it.
|
||||
|
||||
After that, go to one of the examples, such as
|
||||
[**`1-hello`**](https://github.com/aantron/dream/tree/master/example/1-hello#files),
|
||||
and try building it:
|
||||
After that, go to one of the examples, such as [**`1-hello`**][1-hello], and
|
||||
try building it:
|
||||
|
||||
```
|
||||
cd example/1-hello
|
||||
dune exec --root . ./hello.exe
|
||||
```
|
||||
|
||||
If you prefer Reason syntax, try example [**`r-hello`**][r-hello] instead.
|
||||
|
||||
You should be able to copy the example out to a completely separate directory,
|
||||
if you didn't use a local `_opam` switch scoped to Dream's clone directory. If
|
||||
you did, you can pin Dream to your clone in a different opam switch with
|
||||
@ -115,13 +116,15 @@ opam pin add dream /path/to/your/clone
|
||||
and start wherever you like, or begin at [**`1-hello`**][1-hello], the Dream
|
||||
version of *Hello, world!*
|
||||
- [**Reason syntax**][reason-examples] — Several of the examples are
|
||||
available in Reason syntax, with more to come over time!
|
||||
available in Reason syntax. See [**`r-hello`**][r-hello].
|
||||
|
||||
- [**Examples**][examples] — These cover various HTTP scenarios.
|
||||
- [**API reference**][api-main]
|
||||
|
||||
[tutorial]: https://github.com/aantron/dream/tree/master/example#readme
|
||||
[examples]: https://github.com/aantron/dream/tree/master/example#examples
|
||||
[1-hello]: https://github.com/aantron/dream/tree/master/example/1-hello#files
|
||||
[r-hello]: https://github.com/aantron/dream/tree/master/example/r-hello#files
|
||||
[reason-examples]: https://github.com/aantron/dream/tree/master/example#reason
|
||||
[api-main]: https://aantron.github.io/dream/#types
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ That's it for the tutorial!
|
||||
|
||||
There are several examples showing Dream with Reason syntax.
|
||||
|
||||
- [**`r-hello`**](r-hello#files)
|
||||
- [**`r-hello`**](r-hello#files) — the simplest Dream server.
|
||||
- [**`r-template`**](r-template#files)
|
||||
- [**`r-template-stream`**](r-template-stream#files)
|
||||
- `r-fullstack`
|
||||
|
||||
@ -2,6 +2,32 @@
|
||||
|
||||
<br>
|
||||
|
||||
This example shows the simplest Dream program one could write:
|
||||
|
||||
```reason
|
||||
let () =
|
||||
Dream.run(_ =>
|
||||
Dream.respond("Good morning, reasonable world!"));
|
||||
```
|
||||
|
||||
<pre><code><b>$ dune exec --root . ./hello.exe</b>
|
||||
08.04.21 13:55:56.552 Running on http://localhost:8080
|
||||
08.04.21 13:55:56.553 Press ENTER to stop
|
||||
</code></pre>
|
||||
|
||||
<br>
|
||||
|
||||
[Up to the tutorial index](../#readme)
|
||||
After starting it, visit [http://localhost:8080](http://localhost:8080), and it
|
||||
will respond with its friendly greeting!
|
||||
|
||||
<br>
|
||||
|
||||
**See also:**
|
||||
|
||||
- [**`r-template`**](../r-template#files) shows templates with Reason syntax.
|
||||
- [**`2-middleware`**](../2-middleware) introduces the *logger*, the most
|
||||
commonly used Dream middleware. The example is in OCaml syntax.
|
||||
|
||||
<br>
|
||||
|
||||
[Up to the example index](../#reason)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user