Skip to content

Instantly share code, notes, and snippets.

@ericstumper
Created June 6, 2016 13:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericstumper/97733fc56cc87d40dfda9e9aff60bb40 to your computer and use it in GitHub Desktop.
Save ericstumper/97733fc56cc87d40dfda9e9aff60bb40 to your computer and use it in GitHub Desktop.
defmodule Languafy.Router do
use Languafy.Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :graphql do
plug Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Poison
plug Guardian.Plug.VerifyHeader, realm: "Bearer"
plug Guardian.Plug.LoadResource
end
if Mix.env == :dev do
get "/graphiql", Absinthe.Plug.GraphiQL, schema: Languafy.Schema
post "/graphiql", Absinthe.Plug.GraphiQL, schema: Languafy.Schema
end
scope "/graphql" do
pipe_through :graphql
forward "/", Absinthe.Plug, schema: Languafy.Schema
end
scope "/", Languafy do
pipe_through :browser # Use the default browser stack
get "*path", PageController, :index
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment