ash_authentication/dev/dev_server/router.ex
James Harton 8797005175
feat(Ash.PlugHelpers): Support standard actor configuration. (#16)
* improvement(docs): change all references to `actor` to `user`.

The word "actor" has special meaning in the Ash ecosystem.

* chore: format `dev` directory also.

* feat(Ash.PlugHelpers): Support standard actor configuration.

* Adds the `:set_actor` plug which will set the actor to a resource based on the subject name.
* Also includes GraphQL and JSON:API interfaces in the devserver for testing.
2022-10-31 16:43:00 +13:00

19 lines
626 B
Elixir

defmodule DevServer.Router do
@moduledoc false
use Plug.Router
plug(Plug.Parsers, parsers: [:urlencoded, :multipart, :json], json_decoder: Jason)
plug(Plug.Session, store: :ets, key: "_ash_authentication_session", table: DevServer.Session)
plug(:fetch_session)
plug(:fetch_query_params)
plug(Plug.Logger)
plug(:match)
plug(:dispatch)
forward("/auth", to: Example.AuthPlug)
get("/clear_session", to: DevServer.ClearSession)
post("/token_check", to: DevServer.TokenCheck)
forward("/api", to: DevServer.ApiRouter)
forward("/gql", to: DevServer.GqlRouter)
forward("/", to: DevServer.WebRouter)
end