112 releases (51 breaking)
Uses new Rust 2024
| new 0.89.2 | Feb 28, 2026 |
|---|---|
| 0.89.0 | Jan 28, 2026 |
| 0.87.1 | Dec 31, 2025 |
| 0.85.0 | Nov 24, 2025 |
| 0.37.6 | Nov 29, 2022 |
#1831 in HTTP server
110,884 downloads per month
Used in 2 crates
(via salvo)
790KB
18K
SLoC
Salvo is an extremely simple and powerful Rust web backend framework. Only basic Rust knowledge is required to develop backend services.
salvo-flash
Flash messages middleware for the Salvo web framework. Flash messages are temporary notifications that persist across a single redirect, commonly used to display success, error, or info messages after form submissions.
Features
- Multiple storage backends: Cookie-based or session-based storage
- Message levels: Debug, Info, Success, Warning, and Error severity levels
- Level filtering: Filter messages by minimum severity level
- Easy integration: Simple API for setting and retrieving flash messages
- Automatic cleanup: Messages are automatically cleared after being read
How It Works
- A handler sets flash messages before redirecting
- The middleware stores them (in cookies or session)
- On the next request, the messages are available and then cleared
Storage Options
| Store | Feature | Description |
|---|---|---|
CookieStore |
cookie-store |
Stores messages in a cookie |
SessionStore |
session-store |
Stores messages in the session |
Installation
This is an official crate, so you can enable it in Cargo.toml:
salvo = { version = "*", features = ["flash"] }
Quick Start
use salvo::prelude::*;
use salvo::flash::{FlashDepotExt, CookieStore};
#[handler]
async fn submit_form(depot: &mut Depot, res: &mut Response) {
// Set flash message before redirect
depot.outgoing_flash_mut().success("Form submitted successfully!");
res.render(Redirect::other("/result"));
}
#[handler]
async fn show_result(depot: &mut Depot, res: &mut Response) {
if let Some(flash) = depot.incoming_flash() {
for msg in flash.iter() {
println!("{}: {}", msg.level, msg.value);
}
}
res.render("Result page");
}
#[tokio::main]
async fn main() {
let router = Router::new()
.hoop(CookieStore::new().into_handler())
.push(Router::with_path("submit").post(submit_form))
.push(Router::with_path("result").get(show_result));
let acceptor = TcpListener::new("0.0.0.0:8698").bind().await;
Server::new(acceptor).serve(router).await;
}
Documentation & Resources
☕ Donate
Salvo is an open source project. If you want to support Salvo, you can ☕ buy me a coffee here.
⚠️ License
Salvo is licensed under either of
-
Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0).
-
MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT).
Dependencies
~22–42MB
~639K SLoC