Closed y12studio closed 10 years ago
Thanks for pointing me this out. It seems bloodless can't properly handle regex expressions in @Route
.
Unfortunately, just removing the tail.isNotEmpty
check will not fix it. This check was added to guarantee the precedence of routes according to its path. For example, consider the following services:
@app.Route('/foo')
serviceA() {
...
}
@app.Route('/foo/bar/:param')
serviceB(String param) {
...
}
Without the check, if a request for /foo/bar/test
is received, the result will be unpredictable, since UrlMatch
will return a match for both routes.
I will have to change the route handling implementation, to guarantee that routes are always tested in the correct order (according to its path).
@luizmineo you are right. looking forward to your new implementation.
After thinking about this problem, I figured out that would be impracticable to accept regex expression in @Route
annotations :(
Although, I changed the route handling implementation to allow @Route
to match subpaths. Example:
@app.Route('/path', matchSubPaths: true)
service() {
...
}
@app.Route('/path/subpath')
serviceB() {
...
}
So, if a request for /path/subpath
is received, then serviceB
is executed, but if a request for /path/another_path is received, service
is executed.
This PR for the urlTemplate.match().tail.isNotEmpty with app.Route(r'/match/.*').