server.helpers

Classes

MocAPI

This is a temporary Middleware class to Moc the API until the

Module Contents

class server.helpers.MocAPI

Bases: fastapi.staticfiles.StaticFiles

This is a temporary Middleware class to Moc the API until the API is filled out over time. The idea is to save static server responses in the ‘static/api/imls’ directory as json files. When the frontend makes API requests, the backend server will respond with the stored responses.

Then, one-by-one, we will re-implement the API endpoint to respond in the same way but by making the appropriate queries to the INN server or the ElasticSearch server as appropriate.

Once all the API endpoints are replicated, we can get rid of this class.

IMPORTANT: the ‘/api/imls’ URL prefix is routed to this class. But, we can add specific routes for, say, ‘/api/imls/search’ to a specific handler without having to make any changes here. That way, this handler will remain as a fallback handler for any URL that doesn’t already have an actual implemented handler.

async get_response(path: str, scope: starlette.types.Scope) starlette.responses.Response

Returns an HTTP response, given the incoming path, method and request headers.