execute_request

Function execute_request 

Source
pub async fn execute_request(
    spec: &CachedSpec,
    matches: &ArgMatches,
    base_url: Option<&str>,
    dry_run: bool,
    idempotency_key: Option<&str>,
    global_config: Option<&GlobalConfig>,
    output_format: &OutputFormat,
    jq_filter: Option<&str>,
    cache_config: Option<&CacheConfig>,
    capture_output: bool,
) -> Result<Option<String>, Error>
Expand description

Executes HTTP requests based on parsed CLI arguments and cached spec data.

This module handles the mapping from CLI arguments back to API operations, resolves authentication secrets, builds HTTP requests, and validates responses.

§Arguments

  • spec - The cached specification containing operation details
  • matches - Parsed CLI arguments from clap
  • base_url - Optional base URL override. If None, uses BaseUrlResolver
  • dry_run - If true, show request details without executing
  • idempotency_key - Optional idempotency key for safe retries
  • global_config - Optional global configuration for URL resolution
  • output_format - Format for response output (json, yaml, table)
  • jq_filter - Optional JQ filter expression to apply to response
  • cache_config - Optional cache configuration for response caching
  • capture_output - If true, captures output and returns it instead of printing to stdout

§Returns

  • Ok(Option<String>) - Request executed successfully. Returns Some(output) if capture_output is true
  • Err(Error) - Request failed or validation error

§Errors

Returns errors for authentication failures, network issues, response validation, or JQ filter errors

§Panics

Panics if JSON serialization of dry-run information fails (extremely unlikely)