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:
parent
a122bf28d2
commit
e7e136195b
1 changed files with 6 additions and 4 deletions
10
src/main.rs
10
src/main.rs
|
@ -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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue