Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed passive voice, added clarity #1162

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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