# `HttpDouble.Route`
[🔗](https://github.com/aszymanskiit/http_double/blob/main/lib/http_double/route.ex#L1)

Representation of a static HTTP route.

Routes can be defined as simple maps or as more advanced structures. This
module normalises external route specifications into a uniform internal form
and provides matching helpers.

# `id`

```elixir
@type id() :: reference()
```

Unique route identifier.

# `t`

```elixir
@type t() :: %HttpDouble.Route{
  body_match: nil | binary() | Regex.t(),
  header_matches: [{String.t(), String.t() | :any | Regex.t()}],
  host: String.t() | nil,
  id: id(),
  method: String.t(),
  path: String.t(),
  path_prefix: String.t() | nil,
  path_regex: Regex.t() | nil,
  query: %{optional(String.t()) =&gt; String.t() | :any},
  response: HttpDouble.response_spec()
}
```

Internal route representation.

# `delete_from_list`

```elixir
@spec delete_from_list([t()], map()) :: [t()]
```

Deletes a route from the list using either `:id` or `{method, path}`.

# `find_match`

```elixir
@spec find_match([t()], HttpDouble.Request.t()) ::
  {:ok, t(), HttpDouble.response_spec()} | :nomatch
```

Finds the first matching route and resolves its response specification.

# `from_spec`

```elixir
@spec from_spec(map()) :: t()
```

Builds a route struct from a user-facing map specification.

Supported keys:

  * `:method` – string or atom, e.g. "GET" or :post
  * `:path` – exact path match
  * `:path_prefix` – prefix match
  * `:path_regex` – regular expression
  * `:host` – optional host match
  * `:query` – map of query parameters, values can be exact strings or `:any`
  * `:headers` – header match map or list of `{name, value}` (value can be string, `:any` or regex)
  * `:body` – exact body match or regex
  * `:response` – response specification (map, `HttpDouble.Response`, callback, etc.)

# `update_in_list`

```elixir
@spec update_in_list([t()], map()) :: [t()]
```

Updates a route inside a route list using either `:id` or `{method, path}`.

---

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