4 releases (2 breaking)

0.3.1 Nov 20, 2019
0.3.0 Nov 20, 2019
0.2.0 Apr 10, 2019
0.1.0 Dec 24, 2018

#1106 in HTTP server

MIT/Apache

25KB
236 lines

Actix Web Flash

Build Status Crates.io dependency status license

Actix web flash is an unofficial crate to provide flash messages in servers using Actix web.

Flash messages are typically used to display errors on websites that are rendered server side.

use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer, Responder};
use actix_web_flash::{FlashMessage, FlashMiddleware, FlashResponse};

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

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

fn main() {
    HttpServer::new(move || {
        App::new()
            .wrap(FlashMiddleware::default())
            .route("/show_flash", web::get().to(show_flash))
            .route("/set_flash", web::get().to(set_flash))
    }).bind("127.0.0.1:8080")
    .unwrap()
    .run()
    .unwrap();
}

License

MIT/Apache-2.0

Dependencies

~26MB
~545K SLoC