Skip to content

Commit a0e274b

Browse files
authored
Mention dbg/2 can be plugged into a pipeline (#1296)
1 parent 8723880 commit a0e274b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/plug/builder.ex

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,23 @@ defmodule Plug.Builder do
123123
halt(conn)
124124
end
125125
end
126+
127+
## Debugging a pipeline
128+
129+
During development, you may wish to display the current state of the connection
130+
at a certain point in the pipeline. This can be achieved by plugging the `dbg/2`
131+
macro from Elixir. Since it accepts and returns the connection as first argument,
132+
and takes options as the second, it just works:
133+
134+
defmodule PlugWithDbg do
135+
use Plug.Builder
136+
137+
plug Plug.RewriteOn
138+
plug :dbg
139+
plug Plug.MethodOverride
140+
plug :dbg, charlists: :as_lists
141+
end
142+
126143
"""
127144

128145
@type plug :: module | atom

0 commit comments

Comments
 (0)