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,12 +425,14 @@ async fn metrics(
config: &State<Config>, config: &State<Config>,
) -> Option<String> { ) -> Option<String> {
if let Some(metrics_config) = &config.metrics { if let Some(metrics_config) = &config.metrics {
if let Some(filter) = &metrics_config.ip_filter { if metrics_config.enabled {
if filter.validate(&address.ip()) { if let Some(filter) = &metrics_config.ip_filter {
if filter.validate(&address.ip()) {
return Some(get_metrics(metrics));
}
} else {
return Some(get_metrics(metrics)); return Some(get_metrics(metrics));
} }
} else {
return Some(get_metrics(metrics));
} }
} }