What does "plug" do?

I don’t know what “plug” does…

defmodule DbServerWeb.Router do
  use DbServerWeb, :router

  pipeline :browser do
    plug :accepts, ["html"]
    plug :fetch_session
    plug :fetch_flash
    plug :protect_from_forgery
    plug :put_secure_browser_headers
  end

  pipeline :api do
    plug :accepts, ["json"]
  end

  scope "/", DbServerWeb do
    pipe_through :browser

    get "/", PageController, :index
  end

  # Other scopes may use custom stacks.
  # scope "/api", DbServerWeb do
  #   pipe_through :api
  # end
end

This is my endpoint.ex.
I can only guess the “plug” is relevant to settings…

Tell me what it does!

https://hexdocs.pm/phoenix/plug.html

1 Like

https://hexdocs.pm/plug/readme.html

1 Like

Thank you for those links

… so these “settings” drive code generation.

1 Like