Packages
route_toggle_plug
0.1.2
Small plug to toggle routes based on their patch by a environment variable or app config
Current section
Files
Jump to
Current section
Files
lib/route_toggle_plug.ex
defmodule RouteTogglePlug do
import Plug.Conn
def init(opts) do
opts
end
def call(conn = %{request_path: path}, paths: paths, key: key) do
if path not in paths || Application.get_env(:route_toggle_plug, key) do
conn
else
conn
|> Plug.Conn.resp(404, "Not found")
|> halt
end
end
def call(conn, _opts) do
conn
end
end