html2pdf_api/integrations/
mod.rs

1//! Web framework integrations.
2//!
3//! This module provides optional integrations with popular Rust web frameworks,
4//! making it easier to use `BrowserPool` in your web applications.
5//!
6//! # Available Integrations
7//!
8//! | Framework | Feature Flag | Module |
9//! |-----------|--------------|--------|
10//! | Actix-web | `actix-integration` | `actix` |
11//! | Rocket | `rocket-integration` | `rocket` |
12//! | Axum | `axum-integration` | `axum` |
13//!
14//! # Enabling Integrations
15//!
16//! Add the desired feature to your `Cargo.toml`:
17//!
18//! ```toml
19//! [dependencies]
20//! html2pdf-api = { version = "0.1", features = ["actix-integration"] }
21//! ```
22//!
23//! # Common Pattern
24//!
25//! All integrations follow a similar pattern:
26//!
27//! 1. Create a `BrowserPool` during application startup
28//! 2. Convert to shared state using `into_shared()`
29//! 3. Register with your framework's state management
30//! 4. Extract the pool in handlers and use `pool.get()`
31//!
32//! # Example (Generic Pattern)
33//!
34//! ```rust,ignore
35//! use html2pdf_api::prelude::*;
36//!
37//! #[tokio::main]
38//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
39//!     // 1. Create pool
40//!     let pool = BrowserPool::builder()
41//!         .factory(Box::new(ChromeBrowserFactory::with_defaults()))
42//!         .build()?;
43//!
44//!     // 2. Warmup
45//!     pool.warmup().await?;
46//!
47//!     // 3. Convert to shared state
48//!     let shared_pool = pool.into_shared();
49//!
50//!     // 4. Pass to your web framework...
51//!
52//!     Ok(())
53//! }
54//! ```
55
56#[cfg(feature = "actix-integration")]
57pub mod actix;
58
59#[cfg(feature = "rocket-integration")]
60pub mod rocket;
61
62#[cfg(feature = "axum-integration")]
63pub mod axum;