2 unstable releases

0.2.0 Sep 26, 2020
0.1.0 Feb 21, 2020

#29 in #flash

Download history 43/week @ 2022-11-29 62/week @ 2022-12-06 55/week @ 2022-12-13 33/week @ 2022-12-20 15/week @ 2022-12-27 54/week @ 2023-01-03 75/week @ 2023-01-10 87/week @ 2023-01-17 108/week @ 2023-01-24 109/week @ 2023-01-31 22/week @ 2023-02-07 24/week @ 2023-02-14 43/week @ 2023-02-21 20/week @ 2023-02-28 36/week @ 2023-03-07 45/week @ 2023-03-14

149 downloads per month

MIT/Apache

16KB
174 lines

actix-flash

Docs Crates.io

Flash message middleware for actix-web 2.0 or 3.0.

Supports actix-web 3.0 by default. For 2.0, use:

actix-flash = { version = "0.2", features = ["v2"], default-features = false }

For actix-web 1.0 support, check out actix-web-flash.

Usage

use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer, Responder};

async fn show_flash(flash: actix_flash::Message<String>) -> impl Responder {
    flash.into_inner()
}

async fn set_flash(_req: HttpRequest) -> actix_flash::Response<HttpResponse, String> {
    actix_flash::Response::with_redirect("This is the message".to_owned(), "/show_flash")
}

#[actix_rt::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(move || {
        App::new()
            .wrap(actix_flash::Flash::default())
            .route("/show_flash", web::get().to(show_flash))
            .route("/set_flash", web::get().to(set_flash))
    })
    .bind("127.0.0.1:8080")?
    .run()
    .await
}

Current version: 0.2.0

License: MIT/Apache-2.0

Dependencies

~1.9–2.8MB
~60K SLoC