Conflicting routes are only detected in validate()
or run()
#672
Labels
feature
Code based project improvement
validate()
or run()
#672
The code below does not generate any exception or error in v1.0+5:
It is only later down the line, when calling
app.run()
, that we get an exception:This is a bit late, and if the routes are defined in various places, it can be difficult to track the offending
CROW_ROUTE
. If the error was raised immediately when creating the route, debugging would be easier.I appreciate there's probably a cost to pay for this check, and that not everyone wants to pay for it on each new added route. An alternative I considered was to explicitly call
validate()
in my code, after adding each route. But unfortunatelycrow::Crow
only expectsvalidate()
to be called once, when all the routes are set up. This is because thevalidated_
internal flag is never reset tofalse
when adding new routes. If it were, then I could just callvalidate()
whenever I want to do error checking.I thought this could be an easy fix, but currently
validate()
does more than just checking, it also sets up the static route and applies the blueprints. These are actions that shouldn't be done multiple times, but they are also not strictly speaking "validation". I think they should probably be separated from the actual route validation, perhaps into a separate function.The text was updated successfully, but these errors were encountered: