# `PhoenixDatastar.Plug`
[🔗](https://github.com/RicoTrevisan/phoenix_datastar/blob/v0.1.16/lib/plug.ex#L1)

Plug for handling PhoenixDatastar requests.

Handles SSE streams and event dispatch:
- GET /path/stream - Maintains SSE connection for server-pushed updates (live views)
- POST /path/_event/:event - Handles events for all views

# `call`
[🔗](https://github.com/RicoTrevisan/phoenix_datastar/blob/v0.1.16/lib/plug.ex#L39)

```elixir
@spec call(
  Plug.Conn.t(),
  keyword()
) :: Plug.Conn.t()
```

Handles incoming requests for Datastar views.

Dispatches based on HTTP method:
- GET: SSE stream connection
- POST: Event dispatch to GenServer

# `init`
[🔗](https://github.com/RicoTrevisan/phoenix_datastar/blob/v0.1.16/lib/plug.ex#L28)

```elixir
@spec init(keyword()) :: keyword()
```

Initializes the plug with options.

## Options

  * `:view` - The view module to handle requests. Required for SSE streams,
    optional for the global event endpoint.

---

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