mirror of
https://github.com/theroyallab/tabbyAPI.git
synced 2026-03-15 00:07:28 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user