Skip to content

Commit

Permalink
Add Stack middleware that allow redirecting to another stack
Browse files Browse the repository at this point in the history
  • Loading branch information
yrashk committed Oct 4, 2012
1 parent 7960639 commit 087e6e7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/middleware/stack.ex
@@ -0,0 +1,14 @@
defmodule Cage.Middleware.Stack do
use Cage.Middleware

def call(conn, state, opts) do
if is_atom(opts), do: opts = [stack: opts]
stack = opts[:stack]
{conn, state} = stack.run(conn, state)
if opts[:stop] == true do
stop(conn, state)
else
{conn, state}
end
end
end

0 comments on commit 087e6e7

Please sign in to comment.