Crates.io | actix-middleware-etag |
lib.rs | actix-middleware-etag |
version | 0.4.2 |
source | src |
created_at | 2022-09-29 08:20:33.103137 |
updated_at | 2024-09-03 11:54:40.113518 |
description | ETag middleware for Actix web >= 4.8 |
homepage | https://github.com/chriswk/actix-middleware-etag |
repository | https://github.com/chriswk/actix-middleware-etag |
max_upload_size | |
id | 676445 |
size | 40,428 |
To use
use actix_web::{web, App, HttpServer, HttpResponse, Error};
use actix_middleware_etag::{Etag};
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(move ||
App::new()
// Add etag headers to your actix application. Calculating the hash of your GET bodies and putting the base64 hash in the ETag header
.wrap(Etag::default())
...
.bind(("127.0.0.1", 8080))?
.run()
.await
}
This will hash all bodies for GET requests and base64 encode the hash as a weak ETag header in the response