Skip to content

Instantly share code, notes, and snippets.

@ifsc01
Created April 20, 2018 06:03
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 ifsc01/91db1b0b31ad624422135743d5ac9fea to your computer and use it in GitHub Desktop.
Save ifsc01/91db1b0b31ad624422135743d5ac9fea to your computer and use it in GitHub Desktop.
defmodule CenterWeb.Router do
use CenterWeb, :router
require Ueberauth
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :auth do
plug Center.UserManager.Pipeline
end
pipeline :ensure_auth do
plug Guardian.Plug.EnsureAuthenticated
plug CenterWeb.CurrentUser
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", CenterWeb do
pipe_through [:browser, :auth] # Use the default browser stack
get "/", PageController, :index
scope "/auth" do
get "/:provider", AuthController, :request
get "/:provider/callback", AuthController, :callback
delete "/logout", AuthController, :delete
end
end
scope "/", CenterWeb do
pipe_through [:browser, :auth, :ensure_auth]
scope "/game", Game, as: :game do
resources "/apps", AppController do
resources "/servers", ServerController
resources "/clients", ClientController
resources "/server_groups", ServerGroupController, except: [:show]
end
end
end
scope "/api", CenterWeb do
pipe_through :api
scope "/client/v1", CenterAPI.Client.V1 do
resources "/servers", ServerController, only: [:index]
get "/version", VersionController, :version
end
scope "/server/v1" do
end
end
scope "/api/swagger" do
pipe_through [:browser, :auth, :ensure_auth]
forward "/", PhoenixSwagger.Plug.SwaggerUI, otp_app: :center, swagger_file: "swagger.json"
end
def swagger_info do
%{
info: %{
version: "1.0",
title: "Center"
},
securityDefinitions: %{
ApiKey: %{
type: "apiKey",
name: "API-KEY",
in: "header",
description: "API Operations require a valid API Key."
}
},
security: [
%{ApiKey: []}
]
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment