Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router validation #637

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Router validation #637

wants to merge 8 commits into from

Conversation

adam-fowler
Copy link
Member

Add Router.validate() to check whether any route paths clash.

Unfortunately cannot add this in buildResponder as it is a throwing function.

@adam-fowler adam-fowler requested a review from Joannis as a code owner December 20, 2024 10:51
Copy link

github-actions bot commented Dec 20, 2024

return true
}
guard trieValues.count > 1 else { return }
for index in 1..<trieValues.count {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is computationally much heavier than it needs to be, though it will catch more routes that overlap.
Let's break down what we want to validate (and why) in a discussion somewhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was intending to catch any route that would never be triggered because a higher priority route was triggered instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optimised this. It now does the validation at the trie node level which is considerably faster

@adam-fowler adam-fowler requested a review from Joannis December 27, 2024 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants