Skip to content

Commit

Permalink
Remove passive voice, add clarity (#1162)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradhanks authored Sep 13, 2023
1 parent 7b859ef commit f265e2c
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions lib/plug/builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,20 @@ defmodule Plug.Builder do
end
end
Multiple plugs can be defined with the `plug/2` macro, forming a pipeline.
The plugs in the pipeline will be executed in the order they've been added
through the `plug/2` macro. In the example above, `Plug.Logger` will be
called first and then the `:hello` function plug will be called on the
resulting connection.
The `plug/2` macro forms a pipeline by defining multiple plugs. Each plug
in the pipeline is executed from top to bottom. In the example above, the
`Plug.Logger` module plug is called before the `:hello` function plug, so
the function plug will be called on the module plug's resulting connection.
`Plug.Builder` also imports the `Plug.Conn` module, making functions like
`send_resp/3` available.
`Plug.Builder` imports the `Plug.Conn` module so functions like `send_resp/3`
are available.
## Options
When used, the following options are accepted by `Plug.Builder`:
* `:init_mode` - the environment to initialize the plug's options, one of
`:compile` or `:runtime`. Defaults `:compile`.
`:compile` or `:runtime`. The default value is `:compile`.
* `:log_on_halt` - accepts the level to log whenever the request is halted
Expand All @@ -45,8 +44,8 @@ defmodule Plug.Builder do
## Plug behaviour
Internally, `Plug.Builder` implements the `Plug` behaviour, which means both
the `init/1` and `call/2` functions are defined.
`Plug.Builder` defines the `init/1` and `call/2` functions by implementing
the `Plug` behaviour.
By implementing the Plug API, `Plug.Builder` guarantees this module is a plug
and can be handed to a web server or used as part of another pipeline.
Expand Down Expand Up @@ -86,9 +85,9 @@ defmodule Plug.Builder do
## Halting a plug pipeline
A plug pipeline can be halted with `Plug.Conn.halt/1`. The builder will
prevent further plugs downstream from being invoked and return the current
connection. In the following example, the `Plug.Logger` plug never gets
`Plug.Conn.halt/1` halts a plug pipeline. `Plug.Builder` prevents plugs
downstream from being invoked and returns the current connection.
In the following example, the `Plug.Logger` plug never gets
called:
defmodule PlugUsingHalt do
Expand Down

0 comments on commit f265e2c

Please sign in to comment.