diff --git a/.gitignore b/.gitignore index c25f922..635af72 100644 --- a/.gitignore +++ b/.gitignore @@ -110,3 +110,5 @@ cdk.out/ .pgdata/ docs/src/api/* +traefik.toml +routes.toml diff --git a/CHANGES.md b/CHANGES.md index 227dbb8..095e876 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/). Note: Minor version `0.X.0` update might break the API, It's recommended to pin `tipg` to minor version: `tipg>=0.1,<0.2` +## [0.6.2] - 2024-01-19 + +- add `root_path` API settings +- fix invalid `url` parsing in HTML responses + ## [0.6.1] - 2024-01-11 - use `spatial_extent` and `datetime_extent` configuration options in `CatalogUpdateMiddleware` and `/refresh` endpoint (author @hrodmn, https://github.com/developmentseed/tipg/pull/164) @@ -276,7 +281,9 @@ Note: Minor version `0.X.0` update might break the API, It's recommended to pin - Initial release -[unreleased]: https://github.com/developmentseed/tipg/compare/0.6.0...HEAD +[unreleased]: https://github.com/developmentseed/tipg/compare/0.6.2...HEAD +[0.6.2]: https://github.com/developmentseed/tipg/compare/0.6.1...0.6.2 +[0.6.1]: https://github.com/developmentseed/tipg/compare/0.6.0...0.6.1 [0.6.0]: https://github.com/developmentseed/tipg/compare/0.5.7...0.6.0 [0.5.8]: https://github.com/developmentseed/tipg/compare/0.5.7...0.5.8 [0.5.7]: https://github.com/developmentseed/tipg/compare/0.5.6...0.5.7 diff --git a/tipg/factory.py b/tipg/factory.py index 5bc5934..e244d92 100644 --- a/tipg/factory.py +++ b/tipg/factory.py @@ -3,6 +3,7 @@ import abc import csv import json +import re from dataclasses import dataclass, field from typing import Any, Callable, Dict, Generator, Iterable, List, Literal, Optional from urllib.parse import urlencode @@ -119,6 +120,9 @@ def create_html_response( ) -> _TemplateResponse: """Create Template response.""" urlpath = request.url.path + if root_path := request.app.root_path: + urlpath = re.sub(r"^" + root_path, "", urlpath) + crumbs = [] baseurl = str(request.base_url).rstrip("/") diff --git a/tipg/main.py b/tipg/main.py index ce398e4..743e926 100644 --- a/tipg/main.py +++ b/tipg/main.py @@ -68,6 +68,7 @@ async def lifespan(app: FastAPI): openapi_url="/api", docs_url="/api.html", lifespan=lifespan, + root_path=settings.root_path, ) # custom template directory diff --git a/tipg/settings.py b/tipg/settings.py index 154adb1..b050136 100644 --- a/tipg/settings.py +++ b/tipg/settings.py @@ -24,6 +24,7 @@ class APISettings(BaseSettings): cors_origins: str = "*" cachecontrol: str = "public, max-age=3600" template_directory: Optional[str] = None + root_path: str = "" add_tiles_viewer: bool = True