Skip to content

🎀 Injects a ribbon into your web application depending on the environment

License

Notifications You must be signed in to change notification settings

stnly/plug_ribbon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

plug_ribbon

Build Status Hex Version License

This Plug module injects a ribbon to your web application in the configured environment.

Used to differentiate between environments.

Motivation

Inspired by rack-dev-mark

Setup

To use plug_ribbon in your projects, edit your mix.exs file and add plug_ribbon as a dependency:

defp deps do
  [
    {:plug_ribbon, "~> 0.2.0"}
  ]
end

Usage

This plug should be one of the last ones in your pipeline.

Add the plug and specify a list of environment atoms that you want the ribbon 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
    plug Plug.Ribbon, [:dev, :staging, :test]
  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
end

After you are done, run mix deps.get in your shell to fetch the dependencies.

The ribbon will display a label with your current environment in capital letters. Mix.env |> Atom.to_string |> String.upcase

Testing

$ mix test

License

See the LICENSE file for more information.

About

🎀 Injects a ribbon into your web application depending on the environment

Resources

License

Stars

Watchers

Forks

Packages

No packages published