Module http_errors

Module http_errors 

Source
Expand description

HTTP error code mapping to Kubernetes status condition reasons.

This module provides utilities for mapping HTTP status codes from the Bindcar API to standardized Kubernetes condition reasons. This enables consistent error handling and troubleshooting across the operator.

§Usage

use bindy::http_errors::{map_http_error_to_reason, map_connection_error};

// When making HTTP calls to Bindcar API
match client.get("http://localhost:8080/zones").send().await {
    Ok(response) => {
        if response.status().is_success() {
            // Handle success
        } else {
            let (reason, message) = map_http_error_to_reason(response.status().as_u16());
            // Set condition with this reason
        }
    }
    Err(e) => {
        let (reason, message) = map_connection_error();
        // Set condition for connection failure
    }
}

Functions§

is_success_status
Check if HTTP status code indicates success (2xx).
map_connection_error
Map connection error to condition reason and message.
map_http_error_to_reason
Map HTTP status code to condition reason and message.
success_reason
Get condition reason for successful operations.