Skip to main content

respond_response

Function respond_response 

Source
pub async fn respond_response(
    respond: &Respond,
    dir_prefix: &str,
    parsed_request: &ParsedRequest,
) -> Result<Response<BoxBody>, Error>
Expand description

Produce the HTTP response for a matched Respond declaration.

§Why the branches are ordered file → text → status → error

The fields are mutually specialised:

  • file_path serves a file (possibly with CSV→JSON conversion).
  • text + status yields a custom-status text response.
  • text alone yields a plain 200 text response.
  • status alone yields an empty body with that status.

Respond::validate rejects nonsensical combinations at startup, so hitting the final Err branch means something slipped past validation — a real bug, not user input.