pipeline v0.1.0 Pipeline

Pipeline is a monad-based alternative to Plug’s builder and router. It offers much of the same functionality.

This module can be use-d into a module in order to build a pipeline:

defmodule MyApp do
  use Pipeline

  def hello(conn, opts) do
    Plug.Conn.send_resp(conn, 200, body)
  end

  def pipeline(options) do
    empty
      ~> plug(Plug.Logger)
      ~> plug(:hello)
  end
end

Summary

Functions

The “unit”. Mainly just useful for chaining off of so things don’t look weird. You can do things like: empty ~> foo ~> bar

Handle some errors

Halt the pipeline

Basically a structural cond or case statement

The ~> operator

The ~>> operator

Functions

ap(a, b)
empty()

The “unit”. Mainly just useful for chaining off of so things don’t look weird. You can do things like: empty ~> foo ~> bar.

error(handler)

Handle some errors.

fmap(a, b)
halt()

Halt the pipeline.

match(patterns)

Basically a structural cond or case statement.

match(predicate, consequent)
match(predicate, consequent, alternate)
plug(plug, options \\ nil)

Use a plug.

plug(plug, options, guards)
a ~> b

The ~> operator.

a ~>> b

The ~>> operator.