specify ambiguous routes
When a path is ambiguous, log the matching routes.
Test are failing. I will check locally what is going wrong.
With eXist-7.0.0-SNAPSHOT we have 11 failing tests (custom authorisation and file upload are affected it seems).
@nverwer I do like the idea of displaying more debug information when a developer wants to learn which routes are ambigous. The way the log message is constructed was and is suboptimal because string operations like concatenation will always be performed before the log message is later discarded. I would rather like to see route definitions to be passed in as additional data
util:log("debug", ("ambiguous route: ", $request-data?path, " matching routes: ", $matching-routes)),
I revisited and tested my proposal and came up with
util:log("debug", map {
"ambiguous route" : $request-data?path,
"matching definitions" : array { $matching-routes?path }
})
Which would give us
[...] DEBUG [...] map{"ambiguous route":"/api/errors/handle","matching definitions":["/api/errors/handle","/api/errors/handle"]}
@nverwer would that be enough information to determine which route definitions are ambigous or do you need more?
I just see that the path is not good enough as both are steh same when in fact it is to different ones. And the specificity and priority might be of interest as well.
Hello @line-o , Since the information about ambiguities is primarily interesting for developers, I would indeed want to see the specificity and priority of the matching routes. So how about something like
util:log("debug", map {
"ambiguous route" : $request-data?path,
"matching definitions" : array { $matching-routes }
})
without the path?
I did not actually try this (yet).
@nverwer and I put our heads together and came up with this solution:
map{
"ambiguous route":"/api/errors/handle",
"method": "get",
"matching definitions":[
map{
"priority": 1,
"specificity": 11,
"pattern": "/api/errors"
},
map{
"priority": 1,
"specificity": 18,
"pattern": "/api/errors/handle"
}
]
}
will be logged for the one (test-)request that matches two routes.
:tada: This PR is included in version 1.9.0 :tada:
The release is available on:
v1.9.0- GitHub release
Your semantic-release bot :package::rocket: