View Source Spaceboy.Middleware behaviour (Spaceboy v0.3.2)

Spaceboy server middleware, roughly similar to Plugs plug

Middleware has to implement two functions init/1 and call/2. For example implementation of middleware please look at Spaceboy.Middleware.Logger module.

Summary

Functions

Run a series of Middlewares at runtime.

Callbacks

call(conn, opts)

@callback call(conn :: Spaceboy.Conn.t(), opts :: any()) :: Spaceboy.Conn.t()

init(opts)

@callback init(opts :: Keyword.t()) :: any()

Functions

run(conn, arg2)

@spec run(conn :: Spaceboy.Conn.t(), [{module(), Keyword.t()}]) :: Spaceboy.Conn.t()

Run a series of Middlewares at runtime.

If any of the plugs halt, the remaining plugs are not invoked. If the given connection was already halted, none of the plugs are invoked either.