mirror of
https://github.com/aantron/dream.git
synced 2025-07-27 00:02:12 -04:00
Compare commits
No commits in common. "5f42c8722761fecc61b8809d24bd5ea852dfec14" and "337a35fb1238b86f10f57d7aacb20003bc0486ba" have entirely different histories.
5f42c87227
...
337a35fb12
@ -26,6 +26,6 @@ lockfile.
|
||||
|
||||
Useful links:
|
||||
|
||||
- OCaml [*Syntax of documentation comments*](https://v2.ocaml.org/manual/ocamldoc.html#ss:ocamldoc-syntax)
|
||||
- OCaml [*Syntax of documentation comments*](http://caml.inria.fr/pub/docs/manual-ocaml/ocamldoc.html#ss:ocamldoc-syntax)
|
||||
- Lambda Soup [*Module Soup*](https://aantron.github.io/lambdasoup/)
|
||||
- Soupault [*Tips and tricks*](https://soupault.app/tips-and-tricks/)
|
||||
|
@ -19,7 +19,7 @@ let () =
|
||||
However, as you can see, the more middlewares we stack on top of each other
|
||||
like this, the more parentheses and indentation we will end up with! To keep
|
||||
the code tidy, we use `@@`, the
|
||||
[standard OCaml operator](https://v2.ocaml.org/api/Stdlib.html#VAL(@@)) for calling functions without parentheses. So, the [actual
|
||||
[standard OCaml operator](https://caml.inria.fr/pub/docs/manual-ocaml/libref/Stdlib.html#VAL(@@)) for calling functions without parentheses. So, the [actual
|
||||
code](https://github.com/aantron/dream/blob/master/example/2-middleware/middleware.ml)
|
||||
in this example looks like this:
|
||||
|
||||
|
@ -54,7 +54,7 @@ file to run the template preprocessor:
|
||||
<br>
|
||||
|
||||
The substitution, `<%s param %>`, uses
|
||||
[`Printf` conversion specifications](https://v2.ocaml.org/api/Printf.html)
|
||||
[`Printf` conversion specifications](https://caml.inria.fr/pub/docs/manual-ocaml/libref/Printf.html)
|
||||
from the standard library. So, you can do things like this:
|
||||
|
||||
- `<%i my_int %>` to print an OCaml `int`.
|
||||
|
@ -41,7 +41,7 @@ messages in the log, between the others:
|
||||
```
|
||||
|
||||
Note that this is on `stderr`. As you can see, the functions take
|
||||
[`Printf`-style format strings](https://v2.ocaml.org/api/Printf.html),
|
||||
[`Printf`-style format strings](https://caml.inria.fr/pub/docs/manual-ocaml/libref/Printf.html),
|
||||
so you can quickly print values of various types to the log.
|
||||
|
||||
<br>
|
||||
|
@ -30,7 +30,7 @@ let () =
|
||||
@@ Dream.router([
|
||||
|
||||
Dream.get("/:word", request =>
|
||||
Dream.param(request, "word")
|
||||
Dream.param("word", request)
|
||||
|> Template.render
|
||||
|> Dream.html),
|
||||
|
||||
|
@ -587,7 +587,7 @@ val set_cookie :
|
||||
easiest way to do so is to pass the value through an encoder like
|
||||
{!Dream.to_base64url}. See {!Dream.set_secret}.
|
||||
- [~expires] sets the [Expires=] attribute. The value is compatible with
|
||||
{{:https://v2.ocaml.org/api/Unix.html#VALgettimeofday}
|
||||
{{:https://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html#VALgettimeofday}
|
||||
[Unix.gettimeofday]}. See
|
||||
{{:https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-07#section-4.1.2.1}
|
||||
RFC 6265bis §4.1.2.1} and
|
||||
@ -735,9 +735,9 @@ val close : stream -> unit promise
|
||||
type buffer =
|
||||
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t
|
||||
(** Byte arrays in the C heap. See
|
||||
{{:https://v2.ocaml.org/api/Bigarray.Array1.html} [Bigarray.Array1]}. This
|
||||
type is also found in several libraries installed by Dream, so their
|
||||
functions can be used with {!Dream.buffer}:
|
||||
{{:http://caml.inria.fr/pub/docs/manual-ocaml/libref/Bigarray.Array1.html}
|
||||
[Bigarray.Array1]}. This type is also found in several libraries installed
|
||||
by Dream, so their functions can be used with {!Dream.buffer}:
|
||||
|
||||
- {{:https://github.com/inhabitedtype/bigstringaf/blob/353cb283aef4c261597f68154eb27a138e7ef112/lib/bigstringaf.mli}
|
||||
[Bigstringaf.t]} in bigstringaf.
|
||||
@ -1251,8 +1251,9 @@ let render message =
|
||||
within template lines.
|
||||
|
||||
The [s] in [<%s code %>] is actually a
|
||||
{{:https://v2.ocaml.org/api/Printf.html} Printf}-style format specification.
|
||||
So, for example, one can print two hex digits using [<%02X code %>].
|
||||
{{:https://caml.inria.fr/pub/docs/manual-ocaml/libref/Printf.html}
|
||||
Printf}-style format specification. So, for example, one can print two hex
|
||||
digits using [<%02X code %>].
|
||||
|
||||
[<%s code %>] automatically escapes the result of [code] using
|
||||
{!Dream.html_escape}. This can be suppressed with [!]. [<%s! code %>] prints
|
||||
@ -1788,9 +1789,11 @@ val logger : middleware
|
||||
val log : ('a, Format.formatter, unit, unit) format4 -> 'a
|
||||
(** Formats a message and logs it. Disregard the obfuscated type: the first
|
||||
argument is a format string as described in the standard library modules
|
||||
{{:https://v2.ocaml.org/api/Printf.html#VALfprintf} [Printf]} and
|
||||
{{:https://v2.ocaml.org/api/Format.html#VALfprintf} [Format]}. The rest of
|
||||
the arguments are determined by the format string. See example
|
||||
{{:http://caml.inria.fr/pub/docs/manual-ocaml/libref/Printf.html#VALfprintf}
|
||||
[Printf]} and
|
||||
{{: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/a-log#files}
|
||||
[a-log]} \[{{:http://dream.as/a-log} playground}\].
|
||||
|
||||
@ -1882,7 +1885,7 @@ val initialize_log :
|
||||
{!Dream.initialize_log} early in program execution.
|
||||
|
||||
- [~backtraces:true], the default, causes Dream to call
|
||||
{{:https://v2.ocaml.org/api/Printexc.html#VALrecord_backtrace}
|
||||
{{:http://caml.inria.fr/pub/docs/manual-ocaml/libref/Printexc.html#VALrecord_backtrace}
|
||||
[Printexc.record_backtrace]}, which makes exception backtraces available.
|
||||
|
||||
- [~async_exception_hook:true], the default, causes Dream to set
|
||||
|
@ -640,7 +640,7 @@ module Make
|
||||
easiest way to do so is to pass the value through an encoder like
|
||||
{!Dream.to_base64url}. See {!Dream.run} argument [~secret].
|
||||
- [~expires] sets the [Expires=] attribute. The value is compatible with
|
||||
{{:https://v2.ocaml.org/api/Unix.html#VALgettimeofday}
|
||||
{{:https://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html#VALgettimeofday}
|
||||
[Unix.gettimeofday]}. See
|
||||
{{:https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-07#section-4.1.2.1}
|
||||
RFC 6265bis §4.1.2.1} and
|
||||
@ -741,9 +741,9 @@ module Make
|
||||
type buffer =
|
||||
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t
|
||||
(** Byte arrays in the C heap. See
|
||||
{{:https://v2.ocaml.org/api/Bigarray.Array1.html} [Bigarray.Array1]}. This
|
||||
type is also found in several libraries installed by Dream, so their
|
||||
functions can be used with {!Dream.buffer}:
|
||||
{{:http://caml.inria.fr/pub/docs/manual-ocaml/libref/Bigarray.Array1.html}
|
||||
[Bigarray.Array1]}. This type is also found in several libraries installed
|
||||
by Dream, so their functions can be used with {!Dream.buffer}:
|
||||
|
||||
- {{:https://github.com/inhabitedtype/bigstringaf/blob/353cb283aef4c261597f68154eb27a138e7ef112/lib/bigstringaf.mli}
|
||||
[Bigstringaf.t]} in bigstringaf.
|
||||
@ -1212,9 +1212,9 @@ module Make
|
||||
within template lines.
|
||||
|
||||
The [s] in [<%s code %>] is actually a
|
||||
{{:https://v2.ocaml.org/api/Printf.html} Printf}-style format
|
||||
specification. So, for example, one can print two hex digits using
|
||||
[<%02X code %>].
|
||||
{{:https://caml.inria.fr/pub/docs/manual-ocaml/libref/Printf.html}
|
||||
Printf}-style format specification. So, for example, one can print two hex
|
||||
digits using [<%02X code %>].
|
||||
|
||||
[<%s code %>] automatically escapes the result of [code] using
|
||||
{!Dream.html_escape}. This can be suppressed with [!]. [<%s! code %>] prints
|
||||
@ -1533,9 +1533,11 @@ module Make
|
||||
val log : ('a, Format.formatter, unit, unit) format4 -> 'a
|
||||
(** Formats a message and logs it. Disregard the obfuscated type: the first
|
||||
argument is a format string as described in the standard library modules
|
||||
{{:https://v2.ocaml.org/api/Printf.html#VALfprintf} [Printf]} and
|
||||
{{:https://v2.ocaml.org/api/Format.html#VALfprintf} [Format]}. The rest of
|
||||
the arguments are determined by the format string. See example
|
||||
{{:http://caml.inria.fr/pub/docs/manual-ocaml/libref/Printf.html#VALfprintf}
|
||||
[Printf]} and
|
||||
{{: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/a-log#files}
|
||||
[a-log]} \[{{:http://dream.as/a-log} playground}\].
|
||||
|
||||
@ -1627,7 +1629,7 @@ module Make
|
||||
{!Dream.initialize_log} early in program execution.
|
||||
|
||||
- [~backtraces:true], the default, causes Dream to call
|
||||
{{:https://v2.ocaml.org/api/Printexc.html#VALrecord_backtrace}
|
||||
{{:http://caml.inria.fr/pub/docs/manual-ocaml/libref/Printexc.html#VALrecord_backtrace}
|
||||
[Printexc.record_backtrace]}, which makes exception backtraces available.
|
||||
|
||||
- [~async_exception_hook:true], the default, causes Dream to set
|
||||
|
Loading…
x
Reference in New Issue
Block a user