Skip to content

Commit

Permalink
Rename Dream.identity to Dream.no_middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
aantron committed Apr 28, 2021
1 parent 37a27c4 commit 42625d1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
25 changes: 19 additions & 6 deletions src/dream.mli
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,20 @@ and route
Dream.get "/logout" admin_logout_handler;
];
]
]}
]} *)

(** {2 Algebra}
The three handler-related types have a vaguely algebraic interpretation:
- Literal handlers are atoms.
- Each literal {!handler} is an atom.
- {!type-middleware} is for sequential composition (product-like).
- {!type-route} is for alternative composition (sum-like).
{!Dream.no_middleware} is {b 1}.
- {!type-route} is for alternative composition (sum-like). {!Dream.no_route}
is {b 0}.
{!Dream.scope} implements a distributive law. *)
{!Dream.scope} implements a left distributive law, making Dream a ring-like
structure. *)

(** {2 Helpers} *)

Expand Down Expand Up @@ -1095,8 +1100,16 @@ val form_tag :
sections of these docs, according to where they are relevant. This section
contains only generic middleware combinators. *)

val identity : middleware
(** Does nothing but call its inner handler. *)
val no_middleware : middleware
(** Does nothing but call its inner handler. Useful for disabling middleware
conditionally during application startup:
{[
if development then
my_middleware
else
Dream.no_middleware
]} *)

val pipeline : middleware list -> middleware
(** Combines a sequence of middlewares into one, such that these two lines are
Expand Down
2 changes: 1 addition & 1 deletion src/pure/inmost.ml
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ let receive websocket =
let close_websocket ?code websocket =
websocket.close code

let identity handler request =
let no_middleware handler request =
handler request

let rec pipeline middlewares handler =
Expand Down

0 comments on commit 42625d1

Please sign in to comment.