Skip to content

Instantly share code, notes, and snippets.

@mndvns
Last active August 30, 2017 22:52
Show Gist options
  • Save mndvns/41bc948f73831b097f5634e8e880396f to your computer and use it in GitHub Desktop.
Save mndvns/41bc948f73831b097f5634e8e880396f to your computer and use it in GitHub Desktop.
state = %Web.Users.User_.GET.State{
bypass: false,
auth: nil,
user: nil,
}
assert state == Web.Users.User_.GET.state()
defmodule Web.Users.User_.GET do
use Mazurka.Resource
option bypass \\ false
option :skip do
true
end
input auth
param user
mediatype Hyper do
action %State{auth: nil} do
%{
"error" => "no auth"
}
end
action %{auth: "admin"} = state do
action(%{state | bypass: true})
end
action %{bypass: true, user: user} do
# does some special stuff
end
action %{user: user} do
# does some regular stuff
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment