Skip to content

Allow Override Static URLs #9

@da3dsoul

Description

@da3dsoul

I don't know what to call this.
In most languages, types are static, and you can easily say:

@route("/menu/image/<image_id>")
def get_by_id(image_id):
    pass

@route("/menu/image/unsorted")
def get_unsorted():
    pass

image_id is clearly an int or str in this context, but when we have a rule that states that get_unsorted should be called, then it should match that exact URL rather than feeding "unsorted" as a parameter to get_by_id.
Due to the fact that rules are stored as a dict, they are not predictably sorted by nature, which makes them fast, at least. When you have a situation like the above, it will randomly work or not work. If it was FIFO, then at least you could define the route that you want to be prioritized first.

The solution I propose is to get all routes that match the url, see if one matches it exactly and use that, then somehow determine which one to use instead if it doesn't match exactly and matches multiple. Ideally, it would tell the developer somehow if there are multiple matches, so developers don't need to chase a typing and regex issue like I did to find this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions