# `PaperTiger.Plug.APIChaos`
[🔗](https://github.com/EnaiaInc/paper_tiger/blob/v1.2.2/lib/paper_tiger/plug/api_chaos.ex#L1)

Plug middleware that injects chaos into API requests.

When API chaos is configured via `PaperTiger.ChaosCoordinator`, this plug
may randomly:
- Timeout requests (sleep then return 504)
- Return rate limit errors (429)
- Return server errors (500/502/503)

## Configuration

    PaperTiger.ChaosCoordinator.configure(%{
      api: %{
        timeout_rate: 0.02,      # 2% of requests timeout
        timeout_ms: 5000,        # How long to sleep before 504
        rate_limit_rate: 0.01,   # 1% get 429
        error_rate: 0.01,        # 1% get 500/502/503
        endpoint_overrides: %{
          "/v1/subscriptions" => :rate_limit  # Always rate limit this endpoint
        }
      }
    })

# `call`

# `init`

---

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