This Plug module injects a ribbon to your web application.
Used to differentiate between environments.
Based on stnly/plug_ribbon, this version is safe to use in exrm & distillery releases.
To use plug_ribbon in your projects, edit your mix.exs file and add plug_ribbon as a dependency:
defp deps do
[
{:plug_ribbon, github: "MikeAlbertFleetSolutions/plug_ribbon"}
]
endThis plug should be one of the last ones in your pipeline.
Add the plug for the specific environments that you want the ribbon to be shown, include the text to be shown.
defmodule MyPhoenixApp.Router do
use MyPhoenixApp.Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
unless Mix.env == :prod do
plug Plug.Ribbon, "Not Prod"
end
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", MyPhoenixApp do
pipe_through :browser # Use the default browser stack
get "/", PageController, :index
end
# Other scopes may use custom stacks.
# scope "/api", Observes do
# pipe_through :api
# end
endAfter you are done, run mix deps.get in your shell to fetch the dependencies.
The ribbon will display the specified label.
mix testdocker build --pull --tag plug_ribbon -f Dockerfile .docker run -it --rm -v ${WORKSPACE}/plug_ribbon:/app -w /app plug_ribbonmix format && mix credo && mix minify && mix test