-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Case insensitive query parameters (#321)
* GetCapabilities returns a 404 * make only query params lowercase * changed middleware to LowerCaseQueryStringMiddleware and made it optional with API setting. * changed middleware to LowerCaseQueryStringMiddleware and made it optional with API setting. Only lowercase of query keys. * changed middleware to LowerCaseQueryStringMiddleware and made it optional with API setting. Hack to lowercase only query keys. * add test case * linting * update changelog Co-authored-by: vincentsarago <vincent.sarago@gmail.com>
- Loading branch information
1 parent
00a57be
commit adbcd13
Showing
5 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Test titiler.application.middleware.LowerCaseQueryStringMiddleware.""" | ||
|
||
|
||
from titiler.application.middleware import LowerCaseQueryStringMiddleware | ||
|
||
from fastapi import FastAPI, Query | ||
|
||
from starlette.testclient import TestClient | ||
|
||
|
||
def test_lowercase_middleware(): | ||
"""Make sure upper and lower case QS are accepted.""" | ||
app = FastAPI() | ||
|
||
@app.get("/route1") | ||
async def route1(value: str = Query(...)): | ||
"""route1.""" | ||
return {"value": value} | ||
|
||
app.add_middleware(LowerCaseQueryStringMiddleware) | ||
|
||
client = TestClient(app) | ||
|
||
response = client.get("/route1?value=lorenzori") | ||
assert response.json() == {"value": "lorenzori"} | ||
|
||
response = client.get("/route1?VALUE=lorenzori") | ||
assert response.json() == {"value": "lorenzori"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters