Skip to main content

Crate centinel_analytica_fastly

Crate centinel_analytica_fastly 

Source
Expand description

Centinel Analytica bot-protection SDK for Fastly Compute.

§Quick start

use centinel_analytica_fastly::Centinel;
use fastly::{Error, Request, Response};

#[fastly::main]
fn main(req: Request) -> Result<Response, Error> {
    Centinel::protect(req, |r| r.send("origin"))
}

§Observability & extensibility

  • CentinelObserver + CentinelEvent: subscribe to lifecycle events (path excluded, validator call start/end/error, decision, script injected). Ship JsonLogObserver for Fastly log endpoints or implement your own.
  • Hooks: mutate the outbound validator request, override the decision, or decorate the block/redirect response.
  • TraceContext: incoming W3C traceparent / tracestate are forwarded to the validator so its span chains under the caller’s trace.

Every block/redirect response carries Server-Timing, x-centinel-decision, and x-centinel-request-id headers for correlation.

Re-exports§

pub use config::CentinelConfig;
pub use config::ConfigError;
pub use config::DEFAULT_EXCLUSION_PATTERN;
pub use decision::CookieData;
pub use decision::CrawlerInfo;
pub use decision::Decision;
pub use decision::ValidationResponse;
pub use decision::MAX_REDIRECT_HTML_SIZE;
pub use hooks::Hooks;
pub use observer::CentinelEvent;
pub use observer::CentinelObserver;
pub use observer::JsonLogObserver;
pub use observer::NoopObserver;
pub use observer::RecorderObserver;
pub use observer::TraceContext;

Modules§

client
Low-level HTTP client for the Centinel validator API.
config
Configuration loaded from the Fastly Config Store named centinel.
decision
Types mirroring the validator API’s response contract.
exclusions
Path-based request filtering.
hooks
Consumer-supplied mutation points fired around the validator call.
observer
Observability surface: lifecycle events, built-in observers, and W3C trace-context propagation.
request
Outbound validator request payload.
script_injection
HTML response rewriting: inject the Centinel collector <script>.

Structs§

Centinel
Entry point for Centinel bot protection.