actix_chain/
lib.rs

1//! Actix-Web service chaining service.
2//!
3//! Provides a simple non-blocking service for chaining together other arbitrary services.
4//!
5//! # Example
6//!
7//! ```
8//! use actix_web::{App, HttpRequest, HttpResponse, Responder, web};
9//! use actix_chain::{Chain, Link};
10//!
11//! async fn might_fail(req: HttpRequest) -> impl Responder {
12//!     if !req.headers().contains_key("Required-Header") {
13//!         return HttpResponse::NotFound().body("Request Failed");
14//!     }
15//!     HttpResponse::Ok().body("It worked!")
16//! }
17//!
18//! async fn default() -> &'static str {
19//!     "First link failed!"
20//! }
21//!
22//! App::new().service(
23//!     Chain::default()
24//!         .link(Link::new(web::get().to(might_fail)))
25//!         .link(Link::new(web::get().to(default)))
26//! );
27//! ```
28
29mod factory;
30mod link;
31pub mod next;
32mod payload;
33mod service;
34
35pub use factory::Chain;
36pub use link::Link;
37pub use service::ChainService;