pigeon.middleware.pipe¶
Module Contents¶
- class pigeon.middleware.pipe.HTTPMessage(headers: dict[str, str], data: str, protocol: str, content_type=None, cookies=None, **kwargs)¶
An HTTP message (obv either response or request)
- abstract property is_error¶
- set_headers(headers)¶
Overwrites headers passed to function
- class pigeon.middleware.pipe.HTTPRequest(method: str, path: str, headers: dict = None, get: dict = None, data=None, files=None, protocol: str = '1.1', content_type=None, **kwargs)¶
Bases:
pigeon.http.message.HTTPMessage
An HTTP message (obv either response or request)
- property is_error¶
- class pigeon.middleware.pipe.HTTPResponse(headers: dict = None, data: str = None, status: int = 200, cookies=None, protocol: str = '1.1', content_type=None, **kwargs)¶
Bases:
pigeon.http.message.HTTPMessage
An HTTP message (obv either response or request)
- property is_error¶
- pigeon.middleware.pipe.error(code: int, request: pigeon.http.request.HTTPRequest | None = None) pigeon.http.response.HTTPResponse | str ¶
Returns the HTTPResponse for the error code provided, request parameter optional
- pigeon.middleware.pipe.log¶
- pigeon.middleware.pipe.preprocess(raw: bytes) pigeon.http.HTTPResponse | pigeon.http.HTTPRequest ¶
Tries to parse the raw request and checks whether the request is valid. If the request is invalid or could not be parsed correctly, an http error response will be returned.
- pigeon.middleware.pipe.process(message: pigeon.http.message.HTTPMessage) pigeon.http.HTTPResponse ¶
Gathers the response from the application logic.
- pigeon.middleware.pipe.postprocess(message: pigeon.http.message.HTTPMessage, response: pigeon.http.HTTPResponse) pigeon.http.HTTPResponse ¶
Modifies some components of the response such as headers to fit in with server-side policies (e.g. CORS).