Skip to main content

governance_layer

Function governance_layer 

Source
pub async fn governance_layer(
    __arg0: State<GovernanceMiddlewareState>,
    request: Request<Body>,
    next: Next,
) -> Response
Expand description

Governance policy evaluation middleware with AppState.

This middleware extracts the agent ID and action from request extensions or headers and evaluates them against governance policies.

If no agent ID is provided, the request passes through (anonymous requests are not subject to agent-level governance).

§Usage

ⓘ
use axum::middleware;

let app = Router::new()
    .route("/api/tools", post(execute_tool))
    .layer(middleware::from_fn_with_state(
        state.clone(),
        governance_layer,
    ));