from abc import ABC, abstractmethod
from clink.com.type import Component
[docs]class IPipeHandler(Component):
pass
[docs]class ILv0Handler(IPipeHandler, ABC):
'''
Receive handling
'''
@abstractmethod
[docs] def handle(self, req, res, env):
'''
:param Request req:
:param Response res:
:param dict env:
'''
pass
[docs]class ILv1Handler(IPipeHandler, ABC):
'''
Pre-Routing handling
'''
@abstractmethod
[docs] def handle(self, req, res):
'''
:param Request req:
:param Response res:
'''
pass
[docs]class ILv2Handler(IPipeHandler, ABC):
'''
Routing
'''
@abstractmethod
[docs] def handle(self, req):
'''
:param Request req:
:rtype: function
'''
pass
[docs]class ILv3Handler(IPipeHandler, ABC):
'''
Pre-Main handling
'''
@abstractmethod
[docs] def handle(self, req, res):
'''
:param Request req:
:param Response res:
'''
pass
[docs]class ILv4Handler(IPipeHandler):
'''
Main handling. It must be function, but we can't define interface
for functions. Here are symbolic interface.
'''
pass
[docs]class ILv5Handler(IPipeHandler, ABC):
'''
Responding handling
'''
@abstractmethod
[docs] def handle(self, req, res):
'''
:param Request req:
:param Response res:
'''
pass
[docs]class ILv6Handler(IPipeHandler, ABC):
'''
Sending handling
'''
@abstractmethod
[docs] def handle(self, req, res, wsgi_send):
'''
:param Request req:
:param Response res:
:param function wsgi_send:
'''
pass
[docs]class ILv7Handler(IPipeHandler, ABC):
'''
Error handling
'''
@abstractmethod
[docs] def handle(self, req, res, e):
'''
:param Request req:
:param Response res:
:param Exception e:
'''
pass
[docs]class ILv8Handler(IPipeHandler, ABC):
'''
Error logging handling
'''
@abstractmethod
[docs] def handle(self, req, res, e):
'''
:param Request req:
:param Response res:
:param Exception e:
'''
pass
[docs]class ILv9Handler(ILv6Handler):
'''
Sending error handling
'''
pass