# `WardrikHTTP.Routes`

Matches a request's method and path to an operation in `WardrikProtocol`'s OpenAPI document.

# `match`

```elixir
@spec match(String.t(), [String.t()]) ::
  {:ok, WardrikProtocol.operation(), %{required(String.t()) =&gt; String.t()}}
  | :error
```

Returns the operation for `method` and the decoded path `segments`, with its path parameters, or
`:error`.

An agent ID takes two segments, or three if the second starts with `@`. A conversation follows
it as `conversations/ID`.

    WardrikHTTP.Routes.match("POST", ["v1", "agents", "acme", "@jon", "triage", "messages"])
    #=> {:ok, %{id: "agent.ask", ...}, %{"agent" => "acme/@jon/triage"}}

    WardrikHTTP.Routes.match("GET", ~w(v1 agents acme triage conversations C1 timeline))
    #=> {:ok, %{id: "agent.timeline", ...}, %{"agent" => "acme/triage/C1"}}

---

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