Skip to content

Instantly share code, notes, and snippets.

@rcdilorenzo
Last active August 29, 2015 14:01
Show Gist options
  • Save rcdilorenzo/a659c26c75192a09ff9d to your computer and use it in GitHub Desktop.
Save rcdilorenzo/a659c26c75192a09ff9d to your computer and use it in GitHub Desktop.
defmodule Controller.Main do
use Weber.Controller
render_when_raise :unauthorized, {:text, 401, "Unauthorized.", []}
layout false
def action(_, conn) do
{:render, [project: "simpleTodo"], []}
end
def add([body: body], _conn) do
{:json, [response: "ok"], [{"Content-Type", "application/json"}]}
end
def unauthorized(_, _) do
raise_and_render :unauthorized
# No return needed
end
def wrong(_, _) do
{:redirect, "/"}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment