Skip to content

Commit

Permalink
feat: add ROOT_PATH to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
giosava94 committed Jul 12, 2024
1 parent f33fb37 commit 4ddf1ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fed_reg/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Settings(BaseSettings):
PROJECT_NAME: str = "Federation-Registry"
DOMAIN: str = "localhost:8000"
API_V1_STR: str = "/api/v1"
ROOT_PATH: str | None = None

@validator("API_V1_STR")
@classmethod
Expand Down Expand Up @@ -81,7 +82,11 @@ def create_doc_url(cls, v: Optional[str], values: Dict[str, Any]) -> str:
if v:
return v
protocol = "http"
link = os.path.join(values.get("DOMAIN"), values.get("API_V1_STR")[1:], "docs")
root_path = values.get("ROOT_PATH", "/")
root_path = root_path[1:] if root_path is not None else ""
link = os.path.join(
values.get("DOMAIN"), root_path, values.get("API_V1_STR")[1:], "docs"
)
return f"{protocol}://{link}"

# BACKEND_CORS_ORIGINS is a JSON-formatted list of origins
Expand Down
1 change: 1 addition & 0 deletions fed_reg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
summary=summary,
title=settings.PROJECT_NAME,
version=version,
root_path=settings.ROOT_PATH,
)
# if settings.BACKEND_CORS_ORIGINS:
# app.add_middleware(
Expand Down

0 comments on commit 4ddf1ed

Please sign in to comment.