# `Alternera.Plugin.HeaderCatalogue`
[🔗](https://github.com/10e-ab/alternera-sdk/blob/v0.9.0/alternera_plugin_sdk/lib/alternera/plugin/header_catalogue.ex#L1)

The HTTP headers an editor suggests when nothing was recorded: the common
request and response header names, each with a line saying what it is,
and the values typically written into each.

It is data, with no LiveView in it, so a step editor, a condition editor
or the assistant can all read it. `Alternera.Plugin.Editor.HeaderSuggestions`
turns it into what a `<.suggest_input>` reads, with the source exchange's
recorded names put first.

Names are spelled the way documentation spells them (`Content-Type`);
HTTP compares them ignoring case, and so do `values/2` and the editors'
merge with recorded names. The framing headers a proxy or its transport
writes (`Content-Length`, `Transfer-Encoding`, `Connection`, `TE`,
`Upgrade`, `Keep-Alive`) are left out: a step that sets them changes
nothing or breaks the message.

A value may be only the start of one: `Bearer ` ends in a space, so a
pick leaves the cursor where the token goes.

# `header`

```elixir
@type header() :: %{name: String.t(), description: String.t(), values: [value()]}
```

A header: its name, what it is, and its typical values (possibly none).

# `side`

```elixir
@type side() :: :request | :response
```

Which message a header is written into.

# `value`

```elixir
@type value() :: %{value: String.t(), description: String.t() | nil}
```

A value typically written into a header, with what it means.

# `headers`

```elixir
@spec headers(side()) :: [header()]
```

The headers of `side`, sorted by name ignoring case.

## Examples

    iex> Alternera.Plugin.HeaderCatalogue.headers(:request) |> Enum.map(& &1.name) |> Enum.take(2)
    ["Accept", "Accept-Encoding"]

# `names`

```elixir
@spec names(side()) :: [String.t()]
```

The header names of `side`, in `headers/1`'s order.

# `values`

```elixir
@spec values(side(), String.t() | nil) :: [value()]
```

The typical values of the header `name` in `side`, matched ignoring case
and surrounding blanks; `[]` for a header without any or not in the
catalogue.

## Examples

    iex> Alternera.Plugin.HeaderCatalogue.values(:request, " content-type ") |> hd()
    %{value: "application/json", description: "JSON"}

---

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