Fix metrics check when disabled

Previously, disabled metrics had no effect and a request to the
`/metrics` route was answered nonetheless.

Remove needles borrow
This commit is contained in:
finga 2021-11-13 19:43:39 +01:00
parent a122bf28d2
commit e7e136195b

View file

@ -425,6 +425,7 @@ async fn metrics(
config: &State<Config>,
) -> Option<String> {
if let Some(metrics_config) = &config.metrics {
if metrics_config.enabled {
if let Some(filter) = &metrics_config.ip_filter {
if filter.validate(&address.ip()) {
return Some(get_metrics(metrics));
@ -433,6 +434,7 @@ async fn metrics(
return Some(get_metrics(metrics));
}
}
}
warn!("Forbidden request for metrics: {:?}", address);