Skip to content

Instantly share code, notes, and snippets.

@satom99
Created August 20, 2017 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satom99/f6b11cde883bae6377c27beae047fe8a to your computer and use it in GitHub Desktop.
Save satom99/f6b11cde883bae6377c27beae047fe8a to your computer and use it in GitHub Desktop.
defmodule Test.ErrorView do
use Phoenix.View, root: ""
def render(path, _) do
[code, format] = path |> String.split(".")
IO.puts "Rendering #{format}"
format
end
end
defmodule Test.Routes.Sample do
use Phoenix.Controller
defexception plug_status: 500
def index(conn, params) do
IO.inspect conn.private # should contain phoenix_format: "json"
raise __MODULE__, plug_status: 400
end
end
defmodule Test.Router do
use Phoenix.Router
pipeline :api do
plug :accepts, ["json"]
end
scope "/", Test.Routes do
pipe_through :api
get "/", Sample, :index
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment