# `Decree.Middleware.Pipeline`
[🔗](https://github.com/sparkle-space/decree/blob/v0.1.0/lib/decree/middleware/pipeline.ex#L1)

Pipeline is a struct used as an argument in the callback functions of modules
implementing the `Decree.Middleware` behaviour.

This struct must be returned by each function to be used in the next
middleware based on the configured middleware chain.

## Pipeline fields

  - `application` - the Decree application.
  
  - `assigns` - shared user data as a map.

  - `causation_id` - an optional UUID used to identify the cause of the
     command being dispatched.

  - `correlation_id` - an optional UUID used to correlate related
     commands/events together.

  - `command` - command struct being dispatched.

  - `command_uuid` - UUID assigned to the command being dispatched.

  - `halted` - flag indicating whether the pipeline was halted.

  - `identity` - an atom specifying a field in the command containing the
     aggregate's identity or a one-arity function that returns an identity
     from the command being dispatched.

  - `identity_prefix` - an optional prefix to the aggregate's identity. It may
     be a string (e.g. "prefix-") or a zero arity function
     (e.g. `&MyRouter.identity_prefix/0`).

  - `identity_opaque` - `true` when the route declared `opaque: true`, so its identity
     may be any non-empty binary rather than a canonical UUID. `false` by default.

  - `metadata` - the metadata map to be persisted along with the events.

  - `response` - sets the response to send back to the caller.

# `assign`

Puts the `key` with value equal to `value` into `assigns` map.

# `assign_metadata`

Puts the `key` with value equal to `value` into `metadata` map.

Note: Use of atom keys in metadata is deprecated in favour of binary strings.

# `chain`

Executes the middleware chain.

# `halt`

Halts the pipeline by preventing further middleware downstream from being invoked.

Prevents dispatch of the command if `halt` occurs in a `before_dispatch` callback.

# `halted?`

Has the pipeline been halted?

# `respond`

Sets the response to be returned to the dispatch caller, unless already set.

# `response`

Extract the response from the pipeline

---

*Consult [api-reference.md](api-reference.md) for complete listing*
