Router

Trie implementation + tests
Router using it + tests
I find it more explicit, it's less lines of code, and prevents a hack. But at the end it's a style preference I guess.
Do as you wish