minor reductions

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-06-17 04:57:41 +00:00
parent 1c0ed91f6f
commit 98d96b89a5
2 changed files with 23 additions and 18 deletions

View file

@ -84,28 +84,28 @@ fn compression_layer(server: &Server) -> tower_http::compression::CompressionLay
#[cfg(feature = "zstd_compression")]
{
if server.config.zstd_compression {
compression_layer = compression_layer.zstd(true);
compression_layer = if server.config.zstd_compression {
compression_layer.zstd(true)
} else {
compression_layer = compression_layer.no_zstd();
compression_layer.no_zstd()
};
};
#[cfg(feature = "gzip_compression")]
{
if server.config.gzip_compression {
compression_layer = compression_layer.gzip(true);
compression_layer = if server.config.gzip_compression {
compression_layer.gzip(true)
} else {
compression_layer = compression_layer.no_gzip();
compression_layer.no_gzip()
};
};
#[cfg(feature = "brotli_compression")]
{
if server.config.brotli_compression {
compression_layer = compression_layer.br(true);
compression_layer = if server.config.brotli_compression {
compression_layer.br(true)
} else {
compression_layer = compression_layer.no_br();
compression_layer.no_br()
};
};
@ -179,11 +179,10 @@ fn catch_panic(err: Box<dyn Any + Send + 'static>) -> http::Response<http_body_u
}
fn tracing_span<T>(request: &http::Request<T>) -> tracing::Span {
let path = if let Some(path) = request.extensions().get::<MatchedPath>() {
path.as_str()
} else {
request.uri().path()
};
let path = request
.extensions()
.get::<MatchedPath>()
.map_or_else(|| request.uri().path(), |p| p.as_str());
tracing::info_span!("router:", %path)
}

View file

@ -167,10 +167,16 @@ impl Console {
}
fn set_history(&self, readline: &mut Readline) {
let history = self.history.lock().expect("locked");
for entry in history.iter().rev() {
readline.add_history_entry(entry.clone());
}
self.history
.lock()
.expect("locked")
.iter()
.rev()
.for_each(|entry| {
readline
.add_history_entry(entry.clone())
.expect("added history entry");
});
}
fn add_history(&self, line: String) {