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