Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
slivingston committed Oct 24, 2024
1 parent 8fdfe70 commit cd183dd
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/bin/rrhttp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,17 @@ impl Config {
}

fn is_valid(&self, req: &Request) -> bool {
let mut matched = false;
for rule in self.rules.iter() {
if req.verb == rule.verb && req.uri == rule.uri {
if self.default == ConfigMode::Allow {
return false;
} else {
matched = true;
break;
// If default is ConfigMode::Block, then match => allow.
return true;
}
}
}
(self.default == ConfigMode::Allow && !matched)
|| (self.default == ConfigMode::Block && matched)
self.default == ConfigMode::Allow
}
}

Expand Down

0 comments on commit cd183dd

Please sign in to comment.