Add the auth pipeline for the Link API path.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
defmodule LinkShortenerWeb.Auth.Pipeline do
|
||||
use Guardian.Plug.Pipeline, otp_app: :link_shortener,
|
||||
module: LinkShortenerWeb.Auth.Guardian,
|
||||
error_handler: LinkShortenerWeb.Auth.ErrorHandler
|
||||
|
||||
plug Guardian.Plug.VerifyHeader
|
||||
plug Guardian.Plug.EnsureAuthenticated
|
||||
plug Guardian.Plug.LoadResource
|
||||
end
|
||||
@@ -17,6 +17,10 @@ defmodule LinkShortenerWeb.Router do
|
||||
plug :accepts, ["json"]
|
||||
end
|
||||
|
||||
pipeline :auth do
|
||||
plug LinkShortenerWeb.Auth.Pipeline
|
||||
end
|
||||
|
||||
scope "/", LinkShortenerWeb do
|
||||
pipe_through :browser
|
||||
|
||||
@@ -29,12 +33,19 @@ defmodule LinkShortenerWeb.Router do
|
||||
pipe_through :api
|
||||
|
||||
scope "/v1", Api.V1, as: :v1 do
|
||||
resources "/links", LinkController
|
||||
post "/users/signup", UserController, :create
|
||||
post "/users/signin", UserController, :signin
|
||||
end
|
||||
end
|
||||
|
||||
scope "/api", LinkShortenerWeb do
|
||||
pipe_through [:api, :auth]
|
||||
|
||||
scope "/v1", Api.V1, as: :v1 do
|
||||
resources "/links", LinkController
|
||||
end
|
||||
end
|
||||
|
||||
# Enables LiveDashboard only for development
|
||||
#
|
||||
# If you want to use the LiveDashboard in production, you should put
|
||||
|
||||
Reference in New Issue
Block a user