# `Arc.Plug`
[🔗](https://github.com/Cratis/Arc.Elixir/blob/main/lib/arc/plug.ex#L4)

The Arc HTTP contract on Plug.

Add it to a Phoenix endpoint, before the router, or to any Plug pipeline:

    plug Arc.Plug, application: MyApp.Arc

Requests that are not Arc routes pass through untouched, so the plug can sit in front of the
rest of your application. It serves:

  * `POST` command routes and `POST <route>/validate`
  * `GET` and `QUERY` query routes, including paging and sorting
  * observable queries as an HTTP snapshot, direct Server-Sent Events and direct WebSocket
  * the multiplexed hubs: WebSocket at `/.cratis/queries/ws` and Server-Sent Events at
    `/.cratis/queries/sse` with its `subscribe` and `unsubscribe` control routes
  * `/.cratis/commands`, `/.cratis/queries`, `/.cratis/me`, `/.cratis/identity-details/schema`,
    `/.cratis/users` and `/.cratis/tenants`

Routes are derived from module names: `MyApp.Authors.Registration.RegisterAuthor` becomes
`POST /api/authors/registration/register-author` with the default `segments_to_skip: 1`.

Use the plug after authentication has run (so `Arc.Authentication` handlers can see the
caller) and before `Plug.Parsers` is optional - Arc reads the body itself when it is unread.

---

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