Skip to main content

resolve_answer_source

Function resolve_answer_source 

Source
pub fn resolve_answer_source(value: &str) -> Result<String, ConfigError>
Expand description

Resolve a single answers map entry into the literal template body the proto layer expects.

The same resolution rule applies to entries at every layer:

  • Listener-level [listeners.<id>.answers] — the global default that fires whenever no more specific override matches.
  • Cluster-level [clusters.<id>.answers] — overrides the listener-level default for the matching status code on requests routed to that cluster.

Two source forms are accepted:

  • Filesystem path — the value starts with the file:// URI scheme. Everything after the prefix is treated as a path; the path is opened and read into a string. Mirrors the on-disk loading the per-status [read_http_answer_file] helper performs for the deprecated answer_301..answer_507 fields.
  • Inline literal (default) — anything else. The value is taken verbatim as the template body, including an empty string (a 0-byte response payload, typical with Connection: close and no headers). The bare-string default keeps the common case — a short canned response — typing-light; operators who need a file say so explicitly with file://.