This is supported on crate feature
compress
only.Expand description
This module provides a middleware Compress
.
Example
use roa::compress::{Compress, Level};
use roa::body::DispositionType::*;
use roa::{App, Context};
use roa::preload::*;
use std::error::Error;
async fn end(ctx: &mut Context) -> roa::Result {
ctx.write_file("../assets/welcome.html", Inline).await
}
let mut app = App::new().gate(Compress(Level::Fastest)).end(end);
let (addr, server) = app.run()?;
// server.await
Ok(())
Structs
A middleware to negotiate with client and compress response body automatically, supports gzip, deflate, brotli, zstd and identity.
Enums
Level of compression data should be compressed with.