mirror of
https://github.com/aantron/dream.git
synced 2025-08-10 00:04:20 -04:00
Reorder some examples
This commit is contained in:
parent
65fe6bd258
commit
29358cf376
@ -40,9 +40,9 @@ When you run this server and visit
|
||||
|
||||
You can write your own messages to the log using
|
||||
[`Dream.log`](https://aantron.github.io/dream/#val-log). See example
|
||||
[**`9-logging`**](../9-logging/#files) for more logging options. Now that we
|
||||
have the logger, we will use it in all other examples, even though it's not
|
||||
really necessary — it just makes it much easier to see what is going on.
|
||||
[**`a-log`**](../a-log/#files) for more logging options. Now that we have the
|
||||
logger, we will use it in all other examples, even though it's not really
|
||||
necessary — it just makes it much easier to see what is going on.
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -45,7 +45,7 @@ Found` when that happens.
|
||||
|
||||
Except for the status code, the `404 Not Found` response is *completely* empty,
|
||||
so it might not display well in your browser. In example
|
||||
[**`8-error`**](../8-error/#files), we will decorate all error responses with
|
||||
[**`9-error`**](../9-error/#files), we will decorate all error responses with
|
||||
an error template in one central location.
|
||||
|
||||
<br>
|
||||
@ -68,8 +68,8 @@ The router can do more than match simple routes:
|
||||
|
||||
- [**`4-counter`**](../4-counter/#files) counts requests, and exposes a special
|
||||
route for getting the count.
|
||||
- [**`5-echo`**](../5-echo/#files) is dynamic in another way: by reading the
|
||||
request body.
|
||||
- [**`5-promise`**](../5-promise/#files) introduces Lwt, the promise library
|
||||
used by Dream.
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -36,9 +36,8 @@ which means they usually also
|
||||
This example's middleware only does something *before* calling the
|
||||
`inner_handler`. To do something *after*, we will need to await the response
|
||||
promise with [Lwt](https://github.com/ocsigen/lwt#readme), the promise library
|
||||
used by Dream. The next example, [**`5-echo`**](../5-echo/#files), already shows
|
||||
a bit of it, but example [**`a-promise`**](../a-promise/#files) introduces Lwt
|
||||
more fully.
|
||||
used by Dream. The next example, [**`5-promise`**](../5-promise/#files), does
|
||||
exactly that!
|
||||
|
||||
<!-- TODO
|
||||
<br>
|
||||
@ -52,10 +51,10 @@ you are writing middleware to publish in a library. It's fine to use a global
|
||||
|
||||
**Next steps:**
|
||||
|
||||
- [**`5-echo`**](../5-echo/#files) responds to `POST` requests and reads their
|
||||
- [**`5-promise`**](../5-promise/#files) shows a middleware that awaits
|
||||
responses using Lwt.
|
||||
- [**`6-echo`**](../6-echo/#files) responds to `POST` requests and reads their
|
||||
bodies.
|
||||
- [**`6-template`**](../6-template/#files) embeds HTML in OCaml... or... OCaml
|
||||
in HTML?
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -15,18 +15,17 @@ list below and jump to whatever interests you!
|
||||
different paths.
|
||||
- [**`4-counter`**](4-counter/#files) — the first *custom*
|
||||
middleware!
|
||||
- [**`5-echo`**](5-echo/#files) — reads request bodies.
|
||||
- [**`6-template`**](6-template/#files) — renders responses
|
||||
from inline HTML templates and guards against XSS.
|
||||
- [**`7-debug`**](7-debug/#files) — includes detailed
|
||||
information
|
||||
about errors in responses.
|
||||
- [**`8-error`**](8-error/#files) — customize all error
|
||||
responses in one place.
|
||||
- [**`9-log`**](9-log/#files) — writing messages to Dream's
|
||||
log.
|
||||
- [**`a-promise`**](a-promise/#files) — introduces Lwt, the
|
||||
- [**`5-promise`**](5-promise/#files) — introduces Lwt, the
|
||||
promise library used by Dream.
|
||||
- [**`6-echo`**](6-echo/#files) — reads request bodies.
|
||||
- [**`7-template`**](7-template/#files) — renders responses
|
||||
from inline HTML templates and guards against XSS.
|
||||
- [**`8-debug`**](8-debug/#files) — includes detailed
|
||||
information about errors in responses.
|
||||
- [**`9-error`**](9-error/#files) — customize all error
|
||||
responses in one place.
|
||||
- [**`a-log`**](a-log/#files) — writing messages to Dream's
|
||||
log.
|
||||
- [**`b-session`**](b-session/#files) — associates state with
|
||||
client sessions.
|
||||
- [**`c-cookie`**](c-cookie/#files) — sets custom cookies.
|
||||
|
@ -48,8 +48,8 @@ and middleware = handler -> handler
|
||||
Examples
|
||||
{{:https://github.com/aantron/dream/tree/master/example/4-counter#files}
|
||||
[4-counter]} and
|
||||
{{:https://github.com/aantron/dream/tree/master/example/a-promise#files}
|
||||
[a-promise]} show user-defined middlewares:
|
||||
{{:https://github.com/aantron/dream/tree/master/example/5-promise#files}
|
||||
[5-promise]} show user-defined middlewares:
|
||||
|
||||
{[
|
||||
let count_requests inner_handler request =
|
||||
@ -102,8 +102,8 @@ and outgoing
|
||||
and 'a promise = 'a Lwt.t
|
||||
(** Dream uses {{:https://github.com/ocsigen/lwt} Lwt} for promises and
|
||||
asynchronous I/O. See example
|
||||
{{:https://github.com/aantron/dream/tree/master/example/a-promise#files}
|
||||
[a-promise]}. *)
|
||||
{{:https://github.com/aantron/dream/tree/master/example/5-promise#files}
|
||||
[5-promise]}. *)
|
||||
|
||||
|
||||
|
||||
@ -590,8 +590,8 @@ val all_cookies : request -> (string * string) list
|
||||
val body : 'a message -> string promise
|
||||
(** Retrieves the entire body. Stores a reference, so {!Dream.body} can be used
|
||||
many times. See example
|
||||
{{:https://github.com/aantron/dream/tree/master/example/5-echo#files}
|
||||
[5-echo]}. *)
|
||||
{{:https://github.com/aantron/dream/tree/master/example/6-echo#files}
|
||||
[6-echo]}. *)
|
||||
|
||||
val with_body : string -> response -> response
|
||||
(** Replaces the body. *)
|
||||
@ -929,8 +929,8 @@ let render message =
|
||||
v}
|
||||
|
||||
See example
|
||||
{{:https://github.com/aantron/dream/tree/master/example/6-template#files}
|
||||
[6-template]}.
|
||||
{{:https://github.com/aantron/dream/tree/master/example/7-template#files}
|
||||
[7-template]}.
|
||||
|
||||
To build the template, add this to [dune]:
|
||||
|
||||
@ -1413,8 +1413,8 @@ val log : ('a, Format.formatter, unit, unit) format4 -> 'a
|
||||
{{:http://caml.inria.fr/pub/docs/manual-ocaml/libref/Format.html#VALfprintf}
|
||||
[Format]}. The rest of the arguments are determined by the format string.
|
||||
See example
|
||||
{{:https://github.com/aantron/dream/tree/master/example/9-log#files}
|
||||
[9-log]}.
|
||||
{{:https://github.com/aantron/dream/tree/master/example/a-log#files}
|
||||
[a-log]}.
|
||||
|
||||
{[
|
||||
Dream.log "Counter is now: %i" counter;
|
||||
@ -1442,8 +1442,8 @@ val error : ('a, unit) conditional_log
|
||||
level} is [`Error] or higher. This scheme is based on the
|
||||
{{:https://erratique.ch/software/logs/doc/Logs/index.html} Logs} library.
|
||||
See example
|
||||
{{:https://github.com/aantron/dream/tree/master/example/9-log#files}
|
||||
[9-log]}.
|
||||
{{:https://github.com/aantron/dream/tree/master/example/a-log#files}
|
||||
[a-log]}.
|
||||
|
||||
{[
|
||||
Dream.error (fun log ->
|
||||
@ -1486,8 +1486,8 @@ val sub_log : string -> sub_log
|
||||
]}
|
||||
|
||||
See [README] of example
|
||||
{{:https://github.com/aantron/dream/tree/master/example/9-log#files}
|
||||
[9-log]}. *)
|
||||
{{:https://github.com/aantron/dream/tree/master/example/a-log#files}
|
||||
[a-log]}. *)
|
||||
|
||||
val initialize_log :
|
||||
?backtraces:bool ->
|
||||
@ -1671,8 +1671,8 @@ type error_handler = error -> response option promise
|
||||
val error_template :
|
||||
(string option -> response -> response promise) -> error_handler
|
||||
(** Builds an {!error_handler} from a template. See example
|
||||
{{:https://github.com/aantron/dream/tree/master/example/8-error#files}
|
||||
[8-error]}.
|
||||
{{:https://github.com/aantron/dream/tree/master/example/9-error#files}
|
||||
[9-error]}.
|
||||
|
||||
{[
|
||||
let my_error_handler =
|
||||
|
Loading…
x
Reference in New Issue
Block a user