Skip to content

Commit

Permalink
Give all example .opam files unique names
Browse files Browse the repository at this point in the history
This simplifies the example command lines. More importantly, it makes it
much easier to vendor Dream into a project.
  • Loading branch information
aantron committed Nov 30, 2023
1 parent 680d5d2 commit 108c3cc
Show file tree
Hide file tree
Showing 84 changed files with 43 additions and 44 deletions.
2 changes: 1 addition & 1 deletion docs/asset/log-sanitized.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

<pre><code><b>$ cd example/2-middleware</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./middleware.exe</b>
<b>$ dune exec ./middleware.exe</b>
<span class="dim">08.03.21 22:19:21.126</span> Running at http://localhost:8080
<span class="dim">08.03.21 22:19:21.126</span> Type Ctrl+C to stop
<span class="dim">08.03.21 22:19:24.927</span> dream.log <span class="info">INFO</span> <span class="odd">REQ 1</span> GET / 127.0.0.1:58549 Mozilla/5.0 ...
Expand Down
Binary file modified docs/asset/log-sanitized.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
2 changes: 1 addition & 1 deletion example/1-hello/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ browser. Your terminal probably makes the link clickable.

<pre><code><b>$ cd example/1-hello</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./hello.exe</b>
<b>$ dune exec ./hello.exe</b>
08.03.21 21:17:21.471 Running at http://localhost:8080
08.03.21 21:17:21.471 Type Ctrl+C to stop
</code></pre>
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion example/3-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let () =

<pre><code><b>$ cd example/3-router</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./router.exe</b></code></pre>
<b>$ dune exec ./router.exe</b></code></pre>

<br>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/4-counter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let () =
```
<pre><code><b>$ cd example/4-counter</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./counter.exe</b></code></pre>
<b>$ dune exec ./counter.exe</b></code></pre>

<br>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/5-promise/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ let () =

<pre><code><b>$ cd example/5-promise</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./promise.exe</b></code></pre>
<b>$ dune exec ./promise.exe</b></code></pre>

Try it in the [playground](http://dream.as/5-promise).

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/6-echo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let () =

<pre><code><b>$ cd example/6-echo</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./echo.exe</b></code></pre>
<b>$ dune exec ./echo.exe</b></code></pre>

...or run it in the [playground](http://dream.as/6-echo).

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/7-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let () =

<pre><code><b>$ cd example/7-template</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./template.exe</b></code></pre>
<b>$ dune exec ./template.exe</b></code></pre>

<br>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/8-debug/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let () =

<pre><code><b>$ cd example/8-debug</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./debug.exe</b></code></pre>
<b>$ dune exec ./debug.exe</b></code></pre>

<br>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/9-error/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let () =

<pre><code><b>$ cd example/9-error</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./error.exe</b></code></pre>
<b>$ dune exec ./error.exe</b></code></pre>

Try it in the [playground](http://dream.as/9-error).

Expand Down
2 changes: 1 addition & 1 deletion example/a-log/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let () =

<pre><code><b>$ cd example/a-log</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./log.exe</b></code></pre>
<b>$ dune exec ./log.exe</b></code></pre>

<br>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/b-session/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let () =

<pre><code><b>$ cd example/b-session</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./session.exe</b></code></pre>
<b>$ dune exec ./session.exe</b></code></pre>

<br>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/c-cookie/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let () =

<pre><code><b>$ cd example/c-cookie</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./cookie.exe</b></code></pre>
<b>$ dune exec ./cookie.exe</b></code></pre>

<br>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/d-form/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ let () =

<pre><code><b>$ cd example/d-form</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./form.exe</b></code></pre>
<b>$ dune exec ./form.exe</b></code></pre>

Try it in the [playground](http://dream.as/d-form).

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/e-json/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ The build commands, as always, are:

<pre><code><b>$ cd example/e-json</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./json.exe</b></code></pre>
<b>$ dune exec ./json.exe</b></code></pre>

You can try this example in the [playground](http://dream.as/e-json).

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/f-static/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Run this example:

<pre><code><b>$ cd example/f-static</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./static.exe</b></code></pre>
<b>$ dune exec ./static.exe</b></code></pre>

...and visit
[http://localhost:8080/static/static.ml](http://localhost:8080/static/static.ml).
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/g-upload/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ let () =

<pre><code><b>$ cd example/g-upload</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./upload.exe</b></code></pre>
<b>$ dune exec ./upload.exe</b></code></pre>

<br>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/h-sql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ let () =

<pre><code><b>$ cd example/h-sql</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./sql.exe</b></code></pre>
<b>$ dune exec ./sql.exe</b></code></pre>

<br>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/i-graphql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ let () =

<pre><code><b>$ cd example/i-graphql</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./graphql.exe</b></code></pre>
<b>$ dune exec ./graphql.exe</b></code></pre>

<br>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/j-stream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let () =

<pre><code><b>$ cd example/j-stream</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./stream.exe</b></code></pre>
<b>$ dune exec ./stream.exe</b></code></pre>

Try running it in the [playground](http://dream.as/j-stream).

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/k-websocket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ let () =

<pre><code><b>$ cd example/k-websocket</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./websocket.exe</b></code></pre>
<b>$ dune exec ./websocket.exe</b></code></pre>

<br>

Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions example/l-https/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let () =

<pre><code><b>$ cd example/l-https</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./https.exe</b></code></pre>
<b>$ dune exec ./https.exe</b></code></pre>

<br>

Expand All @@ -28,7 +28,8 @@ but it is self-signed, and the browser rightly recognizes it as dubious.
For production, be sure to obtain a real certificate, for example, from
[Let's Encrypt](https://letsencrypt.org/). Pass the certificate to
[`Dream.run`](https://aantron.github.io/dream/#val-run) with `~certificate_file`
and `~key_file`.
and `~key_file`. Dream will remind you to do this in the logs if you try to use
the built-in self-signed certificate when not running on localhost.

<br>

Expand Down
File renamed without changes.
8 changes: 3 additions & 5 deletions example/quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e

EXAMPLE=2-middleware
EXE=middleware.exe
DIRECTORY=dream-project
REPO=https://github.com/aantron/dream
if [ "$1" == "" ]
Expand Down Expand Up @@ -64,9 +65,6 @@ eval `opam env`
echo 💲 opam install . --deps-only --yes
opam install . --deps-only --yes

OPAM=$(ls *.opam)
EXE="${OPAM%.*}.exe"

echo
echo -e "\e[0m✅ Building and running example\e[0m"
echo -e "\e[0m✅ When building yourself, be sure to run\e[0m"
Expand All @@ -86,6 +84,6 @@ echo
echo " - This example:" $REPO/tree/$REF/example/$EXAMPLE#files
echo " - Tutorial: " $REPO/tree/$REF/example#tutorial
echo
echo 💲 dune exec --root . ./$EXE
echo 💲 dune exec ./$EXE
echo
dune exec --root . ./$EXE
dune exec ./$EXE
2 changes: 1 addition & 1 deletion example/w-chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The rest of the code hooks up the client's message form to the WebSocket.

<pre><code><b>$ cd example/w-chat</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./chat.exe</b></code></pre>
<b>$ dune exec ./chat.exe</b></code></pre>

<br>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/w-content-security-policy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let () =

<pre><code><b>$ cd example/w-content-security-policy</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./content_security_policy.exe</b></code></pre>
<b>$ dune exec ./content_security_policy.exe</b></code></pre>

<br>

Expand Down
2 changes: 1 addition & 1 deletion example/w-flash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ request, like this:

<pre><code><b>$ cd example/w-flash</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./flash.exe</b></code></pre>
<b>$ dune exec ./flash.exe</b></code></pre>

<br>

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions example/w-fullstack-jsoo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ To run the example, do

<pre><code><b>$ cd example/w-fullstack-jsoo</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune build --root . client/client.bc.js
<b>$ dune build client/client.bc.js
$ mkdir -p static
$ cp _build/default/client/client.bc.js static/client.js
$ dune exec --root . server/server.exe
$ dune exec server/server.exe
</b></code></pre>

Then visit [http://localhost:8080](http://localhost:8080), and you will see...
Expand Down
2 changes: 1 addition & 1 deletion example/w-graphql-subscription/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ let () =

<pre><code><b>$ cd example/w-graphql-subscription</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./graphql_subscription.exe</b></code></pre>
<b>$ dune exec ./graphql_subscription.exe</b></code></pre>

<br>

Expand Down
2 changes: 1 addition & 1 deletion example/w-live-reload/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let () =

<pre><code><b>$ cd example/w-live-reload</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./live_reload.exe</b>
<b>$ dune exec ./live_reload.exe</b>
</code></pre>

<br>
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion example/w-multipart-dump/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Content-Type: application/octet-stream

<pre><code><b>$ cd example/w-multipart-dump</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./multipart_dump.exe</b></code></pre>
<b>$ dune exec ./multipart_dump.exe</b></code></pre>

<br>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/w-one-binary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ To build the whole setup, just do

<pre><code><b>$ cd example/w-one-binary</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./one_binary.exe</b></code></pre>
<b>$ dune exec ./one_binary.exe</b></code></pre>

You can now visit
[http://localhost:8080/assets/camel.jpeg](http://localhost:8080/assets/camel.jpeg)
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion example/w-query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let () =

<pre><code><b>$ cd example/w-query</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./query.exe</b></code></pre>
<b>$ dune exec ./query.exe</b></code></pre>

<br>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/w-stress-response/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ by default. To use,

<pre><code><b>$ cd example/w-stress-response</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./stress_response.exe</b>
<b>$ dune exec ./stress_response.exe</b>
<b>$ curl http://localhost:8080 > /dev/null &</b></code></pre>

The `curl` command can be repeated for multiple concurrent clients, to check
Expand Down
2 changes: 1 addition & 1 deletion example/w-template-files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let () =

<pre><code><b>$ cd example/w-template-files</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./server.exe</b></code></pre>
<b>$ dune exec ./server.exe</b></code></pre>

<br>

Expand Down
2 changes: 1 addition & 1 deletion example/w-template-logic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ let () =

<pre><code><b>$ cd example/w-template-logic</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./template.exe</b></code></pre>
<b>$ dune exec ./template.exe</b></code></pre>

Try it in the [playground](http://dream.as/w-template-logic).

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/w-template-stream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let () =

<pre><code><b>$ cd example/w-template-stream</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./template_stream.exe</b></code></pre>
<b>$ dune exec ./template_stream.exe</b></code></pre>

Try it in the [playground](http://dream.as/w-template-stream).

Expand Down
2 changes: 1 addition & 1 deletion example/w-tyxml/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let () =

<pre><code><b>$ cd example/w-tyxml</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./tyxml.exe</b></code></pre>
<b>$ dune exec ./tyxml.exe</b></code></pre>

Try it in the [playground](http://dream.as/w-tyxml).

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/w-upload-stream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ let () =

<pre><code><b>cd example/w-upload-stream</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . ./upload_stream.exe</b></code></pre>
<b>$ dune exec ./upload_stream.exe</b></code></pre>

Try it in the [playground](http://dream.as/w-upload-stream).

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/w-watch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and run your server when you make changes.

<pre><code><b>$ cd example/w-watch</b>
<b>$ opam install --deps-only --yes .</b>
<b>$ dune exec --root . --watch ./hello.exe</b></code></pre>
<b>$ dune exec --watch ./hello.exe</b></code></pre>

Note that this requires Dune 3.7.0 or higher.

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 108c3cc

Please sign in to comment.