API: Back to async

According to FastAPI docs, if you're using a generic function, running
it in async will make it more performant (which makes sense since
running def functions for routes will automatically run the caller
through a threadpool).

Tested and everything works fine.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2024-03-04 22:59:10 -05:00 committed by Brian Dashore
parent b0c295dd2f
commit d2c6ae2d35
2 changed files with 24 additions and 20 deletions

View file

@ -76,7 +76,9 @@ def load_auth_keys(disable_from_config: bool):
)
def check_api_key(x_api_key: str = Header(None), authorization: str = Header(None)):
async def check_api_key(
x_api_key: str = Header(None), authorization: str = Header(None)
):
"""Check if the API key is valid."""
# Allow request if auth is disabled
@ -102,7 +104,9 @@ def check_api_key(x_api_key: str = Header(None), authorization: str = Header(Non
raise HTTPException(401, "Please provide an API key")
def check_admin_key(x_admin_key: str = Header(None), authorization: str = Header(None)):
async def check_admin_key(
x_admin_key: str = Header(None), authorization: str = Header(None)
):
"""Check if the admin key is valid."""
# Allow request if auth is disabled