Skip to content

Commit

Permalink
add Depends example
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonildoAlbani committed Jul 20, 2022
1 parent 1ce2f99 commit 3a4f19f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from fastapi import FastAPI
from typing import Union
from fastapi import FastAPI, Depends
from src.application.routers import users


Expand All @@ -8,3 +9,13 @@
@app.get("/")
async def home():
return {"status": "ok"}

class CommonQueryParams:
def __init__(self, q: Union[str, None] = None, skip: int = 0, limit: int = 100):
self.q = q
self.skip = skip
self.limit = limit

@app.get("/search")
async def search(commons: CommonQueryParams = Depends(CommonQueryParams)):
return {"commons": commons}

0 comments on commit 3a4f19f

Please sign in to comment.