mirror of
https://github.com/fastapi/fastapi.git
synced 2025-12-30 09:39:20 -05:00
Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com> Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
22 lines
504 B
Python
22 lines
504 B
Python
from fastapi import Depends, FastAPI
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class FixedContentQueryChecker:
|
|
def __init__(self, fixed_content: str):
|
|
self.fixed_content = fixed_content
|
|
|
|
def __call__(self, q: str = ""):
|
|
if q:
|
|
return self.fixed_content in q
|
|
return False
|
|
|
|
|
|
checker = FixedContentQueryChecker("bar")
|
|
|
|
|
|
@app.get("/query-checker/")
|
|
async def read_query_check(fixed_content_included: bool = Depends(checker)):
|
|
return {"fixed_content_in_query": fixed_content_included}
|