BrowserPoolActixExt

Trait BrowserPoolActixExt 

Source
pub trait BrowserPoolActixExt {
    // Required method
    fn into_actix_data(self) -> BrowserPoolData;
}
Expand description

Extension trait for BrowserPool with Actix-web helpers.

Provides convenient methods for integrating with Actix-web.

§Example

use html2pdf_api::integrations::actix::BrowserPoolActixExt;

let pool = BrowserPool::builder()
    .factory(Box::new(ChromeBrowserFactory::with_defaults()))
    .build()?;

pool.warmup().await?;

// Convert directly to Actix-web Data
let pool_data = pool.into_actix_data();

HttpServer::new(move || {
    App::new()
        .app_data(pool_data.clone())
        .configure(configure_routes)
})

Required Methods§

Source

fn into_actix_data(self) -> BrowserPoolData

Convert the pool into Actix-web Data wrapper.

This is equivalent to calling into_shared() and then wrapping with web::Data::new().

§Example
use html2pdf_api::integrations::actix::BrowserPoolActixExt;

let pool = BrowserPool::builder()
    .factory(Box::new(ChromeBrowserFactory::with_defaults()))
    .build()?;

let pool_data = pool.into_actix_data();

HttpServer::new(move || {
    App::new()
        .app_data(pool_data.clone())
})

Implementors§