mirror of
https://github.com/invariantlabs-ai/invariant-gateway.git
synced 2026-07-12 21:36:32 +02:00
support case without request
This commit is contained in:
@@ -3,4 +3,4 @@
|
||||
# If you want to push to a local instance of explorer, then specify the app-api docker container name like:
|
||||
# http://<app-api-docker-container-name>:8000 to push to the local explorer instance.
|
||||
INVARIANT_API_URL=https://explorer.invariantlabs.ai
|
||||
GUADRAILS_API_URL=https://explorer.invariantlabs.ai
|
||||
GUADRAILS_API_URL=https://explorer.invariantlabs.ai
|
||||
@@ -9,12 +9,15 @@ import fastapi
|
||||
from httpx import HTTPStatusError
|
||||
|
||||
|
||||
def extract_policy_from_headers(request: fastapi.Request) -> Optional[str]:
|
||||
def extract_policy_from_headers(request: Optional[fastapi.Request]) -> Optional[str]:
|
||||
"""
|
||||
Extracts the guardrailing policy from the request headers if present.
|
||||
|
||||
Returns 'None' if no such header is present.
|
||||
"""
|
||||
if request is None:
|
||||
return None
|
||||
|
||||
policy = request.headers.get("Invariant-Guardrails")
|
||||
# undo unicode_escape
|
||||
if policy:
|
||||
|
||||
Reference in New Issue
Block a user