INNER CODE UNIT · Rust
module
nginx/nginx-gateway-fabric · internal/controller/nginx/modules/rust/ai-guardrails/src/lib.rs:50
fn module() -> &'static ngx_module_t {
unsafe { &*ptr::addr_of!(ngx_http_guardrails_module) }
}
unsafe extern "C" fn postconfiguration(cf: *mut ngx_conf_t) -> ngx_int_t {
unsafe {
// Register header filter (two-state: suppress on first pass, commit on second).
// Must be registered before body filters so it sits at the top of the header chain.
ctx::NGX_HTTP_NEXT_HEADER_FILTER = ngx_http_top_header_filter;
ngx_http_top_header_filter = Some(guardrails_header_filter);
// Register request body filter (pass-through only). Request inspection
// now happens in the ACCESS phase handler below so it can be performed
// asynchronously (non-blocking) via an NGINX subrequest.
ctx::NGX_HTTP_NEXT_REQUEST_BODY_FILTER = ngx_http_top_request_body_filter;
ngx_http_top_request_body_filter = Some(guardrails_request_body_filter);
// Register response body filter for response inspection