mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 05:14:07 +00:00
implement details endpoint in Python servers
This commit is contained in:
@@ -18,9 +18,9 @@ from starlette.requests import Request
|
||||
from starlette.middleware import Middleware
|
||||
from starlette.middleware.cors import CORSMiddleware
|
||||
|
||||
from nominatim.config import Configuration
|
||||
from nominatim.api import NominatimAPIAsync
|
||||
import nominatim.api.v1 as api_impl
|
||||
from nominatim.config import Configuration
|
||||
|
||||
class ParamWrapper(api_impl.ASGIAdaptor):
|
||||
""" Adaptor class for server glue to Starlette framework.
|
||||
@@ -38,14 +38,18 @@ class ParamWrapper(api_impl.ASGIAdaptor):
|
||||
return self.request.headers.get(name, default)
|
||||
|
||||
|
||||
def error(self, msg: str) -> HTTPException:
|
||||
return HTTPException(400, detail=msg)
|
||||
def error(self, msg: str, status: int = 400) -> HTTPException:
|
||||
return HTTPException(status, detail=msg)
|
||||
|
||||
|
||||
def create_response(self, status: int, output: str, content_type: str) -> Response:
|
||||
return Response(output, status_code=status, media_type=content_type)
|
||||
|
||||
|
||||
def config(self) -> Configuration:
|
||||
return cast(Configuration, self.request.app.state.API.config)
|
||||
|
||||
|
||||
def _wrap_endpoint(func: api_impl.EndpointFunc)\
|
||||
-> Callable[[Request], Coroutine[Any, Any, Response]]:
|
||||
async def _callback(request: Request) -> Response:
|
||||
|
||||
Reference in New Issue
Block a user