Users can access their items via API. Authentication via API token. No public access to items.

This commit is contained in:
2026-04-22 10:32:42 +02:00
parent 6076654aa4
commit b077a1c81c
7 changed files with 143 additions and 1 deletions

View File

@ -17,16 +17,28 @@ defmodule GenericRestServerWeb.Router do
plug :accepts, ["json"]
end
pipeline :protected_api do
plug :accepts, ["json"]
plug :fetch_current_scope_for_api_user
end
scope "/", GenericRestServerWeb do
pipe_through :browser
get "/", PageController, :home
end
# Other scopes may use custom stacks.
# public API
scope "/api", GenericRestServerWeb do
pipe_through :api
post "/log_in", UserTokenController, :log_in
end
# protected API
scope "/api", GenericRestServerWeb do
pipe_through :protected_api
resources "/items", ItemController, except: [:new, :edit]
end