-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Hello!
I saw that the router was advertised as type safe. This was exciting as no one has managed to do this yet, so I read the code to see how it works, but I found some problems:
The router is not type safe as none of the properties of the route path and its parameters are encoded in the type system, and nothing ensures that the handler for a route is correct for the route. If the path parameters are changed then there are no type errors, and the handler will start to fail at runtime.
RE performance, the router performs a linear search of all routes, and it parses all the path patterns each time a request comes in. This is very slow, and would have a notable impact on the performance of web services made with Dream.
The performance issue could be improved by pre-compiling the routes into some optimised data structure like a radix trie, though it would be challenging to get performance comparable to pattern matching. I don't know how the type safety issue could be resolved unfortunately.
Thanks,
Louis