Created
August 20, 2017 16:46
-
-
Save satom99/f6b11cde883bae6377c27beae047fe8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Test.ErrorView do | |
use Phoenix.View, root: "" | |
def render(path, _) do | |
[code, format] = path |> String.split(".") | |
IO.puts "Rendering #{format}" | |
format | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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