# `Macaw.Component.Proxy`
[🔗](https://github.com/dcoai/macaw_component/blob/v0.1.2/lib/macaw/component/proxy.ex#L1)

Proxy routes (spec/01 §1.8): media a component needs from another origin, fetched by the
host's one same-origin proxy, so a page holds same-origin URLs only.

    iex> route = %{name: "tiles", url: "https://tiles.example/{z}/{x}/{y}.png", types: ["image/png"]}
    iex> Macaw.Component.Proxy.path("geo.map", route, %{"z" => "1", "x" => "0", "y" => "0"})
    {:ok, "/macaw/proxy/geo.map/tiles?x=0&y=0&z=1"}

# `route`

```elixir
@type route() :: %{name: String.t(), url: String.t(), types: [String.t(), ...]}
```

# `path`

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

The same-origin path a render uses for a route of a component:
`/macaw/proxy/<component>/<route>?<values>`, the values query-encoded in name order.
Every placeholder needs a value: `{:error, {:placeholders, missing}}` otherwise.

# `placeholders`

```elixir
@spec placeholders(route()) :: [String.t()]
```

The placeholders a route's URL template names, in order of first appearance.

---

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