Elixir vs Ruby on Rails

@tristan @ityonemo Plug pipeline is quite simple conceptually, it is different way to write Enum.reduce_while/3:

conn = conn_from_req(request)

plugs_list
|> Enum.reduce_while(conn, fn {mod, opts}, conn ->
  case mod.call(conn, mod.init(opts)) do
    %Plug.Conn{halt: true} = next ->
      {:halt, next}
    %Plug.Conn{} = next ->
      {:cont, next}
  end
end)
|> resp_from_conn()
3 Likes