allow to add php-compatible endpoints

If the new setting NOMINATIM_SERVE_LEGACY_URLS is set, the servers
expose the endpoints also with the .php suffix to ensure backwards
compatibility.
This commit is contained in:
Sarah Hoffmann
2023-01-24 21:36:45 +01:00
parent e490a30a4a
commit f85b0c6208
4 changed files with 21 additions and 3 deletions

View File

@@ -61,8 +61,12 @@ def get_application(project_dir: Path,
config = Configuration(project_dir, environ)
routes = []
legacy_urls = config.get_bool('SERVE_LEGACY_URLS')
for name, func in api_impl.ROUTES:
routes.append(Route(f"/{name}", endpoint=_wrap_endpoint(func)))
endpoint = _wrap_endpoint(func)
routes.append(Route(f"/{name}", endpoint=endpoint))
if legacy_urls:
routes.append(Route(f"/{name}.php", endpoint=endpoint))
middleware = []
if config.get_bool('CORS_NOACCESSCONTROL'):