API for adding patterns
ahopkins opened this issue · comments
Adam Hopkins commented
Currently .patterns
supports a fixed set of patterns using REGEX_TYPES
.
This should be expanded so that custom patterns can be added at run time.
router.register_pattern("ipv4", ipaddress.ip_address, r"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$")
Then, it should be usable:
@app.route("/foo/<ip:ipv4>")
async def handler(request, ip: IPv4Address):
....
Adam Hopkins commented
Included in #30