Skip to content

Commit

Permalink
allow trailing slash settings.base_url
Browse files Browse the repository at this point in the history
  • Loading branch information
arbakker committed Nov 21, 2023
1 parent c0eeec5 commit 1c619a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/coordinates_transformation_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,28 +161,28 @@ async def landingpage(): # type: ignore # noqa: ANN201
self = Link(
title="API Landing Page",
rel="self",
href=f"{app_settings.base_url}/?f=json",
href=f"{app_settings.base_url.rstrip('/')}/?f=json",
type="application/json",
)

oas = Link(
title="Open API Specification as JSON",
rel="service-desc",
href=f"{app_settings.base_url}/openapi?f=json",
href=f"{app_settings.base_url.rstrip('/')}/openapi?f=json",
type="application/openapi+json",
)

oas_html = Link(
title="Open API Specification as HTML",
rel="service-desc",
href=f"{app_settings.base_url}/openapi?f=html",
href=f"{app_settings.base_url.rstrip('/')}/openapi?f=html",
type="text/html",
)

conformance = Link(
title="Conformance Declaration as JSON",
rel="http://www.opengis.net/def/rel/ogc/1.0/conformance",
href=f"{app_settings.base_url}/conformance",
href=f"{app_settings.base_url.rstrip('/')}/conformance",
type="application/json",
)
return LandingPage(
Expand Down
2 changes: 1 addition & 1 deletion src/coordinates_transformation_api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class AppSettings(BaseSettings):
)
base_url: str = Field(
alias="BASE_URL",
default="http://localhost:8000",
default="http://localhost:8000/",
description="base url on wich the API is served",
pattern=r"^((https?:\/\/)?[\w-]+(\.[\w-]+)*\.?(:\d+)?(\/\S*)?)", # adapted from https://codegolf.stackexchange.com/a/480
)
Expand Down

0 comments on commit 1c619a6

Please sign in to comment.