Skip to content

Commit

Permalink
support servefile zstd
Browse files Browse the repository at this point in the history
  • Loading branch information
randomairborne committed Dec 20, 2023
1 parent 6f964b1 commit 43b0ca0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tower-http/src/services/fs/serve_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ impl ServeFile {
Self(self.0.precompressed_deflate())
}

/// Informs the service that it should also look for a precompressed zstd
/// version of the file.
///
/// If the client has an `Accept-Encoding` header that allows the zstd encoding,
/// the file `foo.txt.zst` will be served instead of `foo.txt`.
/// If the precompressed file is not available, or the client doesn't support it,
/// the uncompressed version will be served instead.
/// Both the precompressed version and the uncompressed version are expected
/// to be present in the same directory. Different precompressed
/// variants can be combined.
pub fn precompressed_zstd(self) -> Self {
Self(self.0.precompressed_zstd())
}

/// Set a specific read buffer chunk size.
///
/// The default capacity is 64kb.
Expand Down

0 comments on commit 43b0ca0

Please sign in to comment.