Skip to content

Commit

Permalink
Hotfix dynamic pygeoapi context
Browse files Browse the repository at this point in the history
  • Loading branch information
francbartoli committed Nov 2, 2024
1 parent a2651f4 commit 79924b9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,6 @@ dmypy.json
.DS_Store
.aider*

# fastgeoapi
/pygeoapi-openapi.json
pygeoapi-openapi.yml
5 changes: 3 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ async def custom_app_exception_handler(request, e):
# override pygeoapi os variables
os.environ["PYGEOAPI_CONFIG"] = cfg.PYGEOAPI_CONFIG
os.environ["PYGEOAPI_OPENAPI"] = cfg.PYGEOAPI_OPENAPI
os.environ["PYGEOAPI_BASEURL"] = cfg.PYGEOAPI_BASEURL
if not (os.environ["PYGEOAPI_CONFIG"] and os.environ["PYGEOAPI_OPENAPI"]):
logger.error("pygeoapi variables are not configured")
raise PygeoapiEnvError("PYGEOAPI_CONFIG and PYGEOAPI_OPENAPI are not set")
else:
# fill pygeoapi configuration with fastapi host and port
# fill pygeoapi configuration with host, port, base url and context
os.environ["HOST"] = cfg.HOST
os.environ["PORT"] = cfg.PORT
os.environ["PYGEOAPI_BASEURL"] = cfg.PYGEOAPI_BASEURL
os.environ["FASTGEOAPI_CONTEXT"] = cfg.FASTGEOAPI_CONTEXT

# prepare pygeoapi openapi file if it doesn't exist
pygeoapi_conf = Path.cwd() / os.environ["PYGEOAPI_CONFIG"]
Expand Down
2 changes: 1 addition & 1 deletion pygeoapi-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ server:
bind:
host: ${HOST}
port: ${PORT}
url: ${PYGEOAPI_BASEURL}/geoapi
url: ${PYGEOAPI_BASEURL}${FASTGEOAPI_CONTEXT}
mimetype: application/json; charset=UTF-8
encoding: utf-8
gzip: false
Expand Down

0 comments on commit 79924b9

Please sign in to comment.