pub struct DebugConfig {
pub enabled: bool,
pub debug_header: Option<String>,
pub debug_token: Option<String>,
pub allow_unauthenticated: bool,
}Expand description
Debug configuration for secure debug mode access.
This allows configuring a debug header that must be present with a secret token for debug information to be included in responses.
§Example
use fastapi_core::error::DebugConfig;
// Require X-Debug-Token header with a secret
let config = DebugConfig::new()
.with_debug_header("X-Debug-Token", "my-secret-token");
// Or allow debug mode without authentication (dangerous!)
let config = DebugConfig::new().allow_unauthenticated();Fields§
§enabled: boolEnable debug mode for the application.
debug_header: Option<String>Header name for debug token authentication.
debug_token: Option<String>Expected token value for debug access.
allow_unauthenticated: boolAllow debug mode without authentication (dangerous in production).
Implementations§
Source§impl DebugConfig
impl DebugConfig
Sourcepub fn with_debug_header(
self,
header_name: impl Into<String>,
token: impl Into<String>,
) -> Self
pub fn with_debug_header( self, header_name: impl Into<String>, token: impl Into<String>, ) -> Self
Configure the debug header and token for authenticated debug access.
When configured, debug information will only be included in responses if the request includes this header with the expected token value.
Sourcepub fn allow_unauthenticated(self) -> Self
pub fn allow_unauthenticated(self) -> Self
Allow debug mode without authentication.
§Warning
This is dangerous in production as it exposes internal details to anyone. Only use for development/testing.
Check if a request is authorized for debug mode.
Returns true if:
- Debug mode is disabled (debug info won’t be shown anyway)
allow_unauthenticatedis true- The request includes the correct debug header/token
§Security
Token comparison uses constant-time comparison to prevent timing attacks.
Trait Implementations§
Source§impl Clone for DebugConfig
impl Clone for DebugConfig
Source§fn clone(&self) -> DebugConfig
fn clone(&self) -> DebugConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more