Skip to content

cheeyeo/plug_playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PlugExercise

Exercise on learning and using Plugs in Elixir.

## Running

mix deps.get
mix compile

mix test

Types of plugs:

  • All plugs must define two methods: init and call

  • Function plugs:

    Methods declared within module which takes a Plug.Conn and optional options and do some transformation.

  • Module Plugs:

    Standalone module which can be used by specifiying a plug command

    plug MyPlug
  • Plugs are chainable:

plug :one
plug :two
plug :three


def one(conn,_opts) do
  # transformation
end

def two(conn,_opts) do
  # transformation
end

def three(conn,_opts) do
  # return final data and transformation
end

About

Exercise in using Elixir Plug

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages