How to make "URL" case insensitive (globally)? #1644
from litestar import Litestar, get
@get("/AbC")
def hello_world() -> dict[str, str]:
return {"hello": "world"}
app = Litestar(route_handlers=[hello_world])
if __name__ == '__main__':
import uvicorn
uvicorn.run('0:app')Microsoft Windows [Version 10.0.19044.2846]
(c) Microsoft Corporation. All rights reserved.
C:\Users\User-PC>curl http://127.0.0.1:8000/AbC
{"hello":"world"}
C:\Users\User-PC>curl http://127.0.0.1:8000/ABC
{"status_code":404,"detail":"Not Found"}
C:\Users\User-PC>curl http://127.0.0.1:8000/abc
{"status_code":404,"detail":"Not Found"}
C:\Users\User-PC>curl http://127.0.0.1:8000/aBc
{"status_code":404,"detail":"Not Found"}
C:\Users\User-PC> |
Answered by
Goldziher
May 10, 2023
Replies: 3 comments
|
You can't. Our routing is not regex based but trie based. This is a limitation of the design. |
0 replies
Answer selected by
Goldziher
This comment was marked as disruptive content.
This comment was marked as disruptive content.
|
URLs should generally be treated as case-sensitive, since there are no guarantees about case-insensitivity. Technically speaking the scheme and host part are case-insensitive, while other parts like path and query may be case-sensitive Case-insensitive |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can't. Our routing is not regex based but trie based. This is a limitation of the design.