pub struct Middleware {Show 26 fields
pub authz: Option<Arc<dyn Authorizer>>,
pub auth: Dispatcher,
pub auditor: Option<Arc<dyn Auditor>>,
pub activity: Option<Arc<dyn ActivityEmitter>>,
pub app_id: String,
pub default_auth_provider: String,
pub output_format: String,
pub env: String,
pub verbose: String,
pub dry_run: bool,
pub fields: String,
pub filter: String,
pub expr: String,
pub limit: i64,
pub offset: i64,
pub reason: String,
pub schema: bool,
pub timeout: Option<Duration>,
pub debug: String,
pub interactive: bool,
pub schema_registry: SchemaRegistry,
pub human_views: HumanViewRegistry,
pub config: Arc<ConfigFile>,
pub environments: Option<Arc<Environments>>,
pub flag_policy: FlagPolicy,
pub flag_registry: FlagRegistry,
}Expand description
Cross-cutting command execution state and dependencies.
Middleware is intentionally a plain, cloneable struct so tests and command
handlers can inspect what will be used for a run. Application setup usually
mutates it through CliConfig hooks or ModuleContext.
Fields§
§authz: Option<Arc<dyn Authorizer>>Optional authorization provider.
auth: DispatcherAuth provider dispatcher.
auditor: Option<Arc<dyn Auditor>>Optional audit sink.
activity: Option<Arc<dyn ActivityEmitter>>Optional activity sink.
app_id: StringApplication id used in output metadata.
default_auth_provider: StringFallback auth provider for commands without an explicit provider.
output_format: StringOutput format: json, human, or toon.
env: StringSelected environment.
verbose: StringMetadata verbosity selector.
dry_run: boolWhether mutating commands should short-circuit.
fields: StringUser field projection.
filter: StringJMESPath per-item list predicate.
expr: StringJMESPath whole-result expression.
limit: i64Client-side page size.
offset: i64Client-side page offset.
reason: StringUser reason passed to authorization and audit.
schema: boolWhether schema rendering was requested.
timeout: Option<Duration>Optional command deadline.
debug: StringDebug selector, interpreted by applications.
interactive: boolWhether the invocation is running in interactive mode.
schema_registry: SchemaRegistryOutput schema registry.
human_views: HumanViewRegistryHuman output view registry.
config: Arc<ConfigFile>Loaded per-application config file, shared across the run.
Populated once at startup from <config-base>/<app_id>/config.toml.
Command handlers read it via
CommandContext::config and
module registration via
ModuleContext::config.
environments: Option<Arc<Environments>>Optional first-class environment system.
Set by CliConfig::with_environments
and cloned into each per-run middleware snapshot. Handlers resolve the
active environment through
CommandContext::environment.
flag_policy: FlagPolicyMerged feature-flag visibility policy for this run.
Set by CliConfig’s min_stage/feature_overrides
(via its private flag_policy() helper) when Cli::new
builds middleware, before any module or group is registered. Command-tree
pruning consults this to decide which flagged commands, groups, and
modules remain mounted.
flag_registry: FlagRegistryEvery flagged module/group/command path discovered while pruning the command tree, populated as modules and groups are registered.
Powers flags list/flags info introspection.
Implementations§
Source§impl Middleware
impl Middleware
Sourcepub async fn run<F, Fut, Output>(
&self,
request: MiddlewareRequest<'_>,
command: F,
) -> Result<MiddlewareOutput>where
F: FnOnce(CredentialResolver) -> Fut + Send,
Fut: Future<Output = Result<Output>> + Send,
Output: Into<CommandResult>,
pub async fn run<F, Fut, Output>(
&self,
request: MiddlewareRequest<'_>,
command: F,
) -> Result<MiddlewareOutput>where
F: FnOnce(CredentialResolver) -> Fut + Send,
Fut: Future<Output = Result<Output>> + Send,
Output: Into<CommandResult>,
Runs the middleware chain for a command.
Trait Implementations§
Source§impl Clone for Middleware
impl Clone for Middleware
Source§fn clone(&self) -> Middleware
fn clone(&self) -> Middleware
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more