logo
Expand description

Example

use actix_prerender::Prerender;
use actix_web::{get, http, web, App, HttpRequest, HttpResponse, HttpServer};

#[get("/index.html")]
async fn index(req: HttpRequest) -> &'static str {
    "<p>Hello World!</p>"
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        let prerender = Prerender::build().use_prerender_io("service_token".to_string());

        App::new()
            .wrap(prerender)
            .service(index)
    })
    .bind(("127.0.0.1", 8080))?
    .run()
    .await;

    Ok(())
}

Structs

Builder for Prerender middleware.

Enums