🏷️ add type hints and docstring updates
This commit is contained in:
parent
6c2cfc5297
commit
98ca09b681
1 changed files with 11 additions and 1 deletions
|
@ -1,6 +1,11 @@
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from spiderweb.request import Request
|
from spiderweb.request import Request
|
||||||
from spiderweb.response import HttpResponse
|
from spiderweb.response import HttpResponse
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from spiderweb.server_checks import ServerCheck
|
||||||
|
|
||||||
|
|
||||||
class SpiderwebMiddleware:
|
class SpiderwebMiddleware:
|
||||||
"""
|
"""
|
||||||
|
@ -22,6 +27,10 @@ class SpiderwebMiddleware:
|
||||||
|
|
||||||
def __init__(self, server):
|
def __init__(self, server):
|
||||||
self.server = server
|
self.server = server
|
||||||
|
# If there are any startup checks that need to be run, they should be added
|
||||||
|
# to this list. These checks should be classes that inherit from
|
||||||
|
# spiderweb.server_checks.ServerCheck.
|
||||||
|
self.checks: list[ServerCheck] = []
|
||||||
|
|
||||||
def process_request(self, request: Request) -> HttpResponse | None:
|
def process_request(self, request: Request) -> HttpResponse | None:
|
||||||
# This method is called before the request is passed to the view. You can safely
|
# This method is called before the request is passed to the view. You can safely
|
||||||
|
@ -45,5 +54,6 @@ class SpiderwebMiddleware:
|
||||||
self, request: Request, response: HttpResponse, rendered_response: str
|
self, request: Request, response: HttpResponse, rendered_response: str
|
||||||
) -> str:
|
) -> str:
|
||||||
# This method is called after all the middleware has been processed and receives
|
# This method is called after all the middleware has been processed and receives
|
||||||
# the final rendered response in str form. You can modify the response here.
|
# the final rendered response in str form. You can modify the response here. This
|
||||||
|
# method *must* return a str version of the rendered response.
|
||||||
return rendered_response
|
return rendered_response
|
||||||
|
|
Loading…
Add table
Reference in a new issue