From 554ad88cbd4b28aaef86cf72aca282e80e9fada2 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Thu, 6 Apr 2023 12:32:23 +0300 Subject: [PATCH] doc: add comments --- lnbits/middleware.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lnbits/middleware.py b/lnbits/middleware.py index 99f637e61..b59225df4 100644 --- a/lnbits/middleware.py +++ b/lnbits/middleware.py @@ -67,6 +67,7 @@ class InstalledExtensionMiddleware: if "query_string" not in scope: return True + # parse the URL query string into a `dict` q = parse_qs(scope["query_string"].decode("UTF-8")) user = q.get("usr", [""])[0] if not user: @@ -80,6 +81,11 @@ class InstalledExtensionMiddleware: def _response_by_accepted_type( self, headers: List[Any], msg: str, status_code: HTTPStatus ) -> Union[HTMLResponse, JSONResponse]: + """ + Build an HTTP response containing the `msg` as HTTP body and the `status_code` as HTTP code. + If the `accept` HTTP header is present int the request and contains the value of `text/html` + then return an `HTMLResponse`, otherwise return an `JSONResponse`. + """ accept_header: str = next( ( h[1].decode("UTF-8")