diff options
| author | 2020-10-25 19:50:36 +0000 | |
|---|---|---|
| committer | 2020-10-25 19:50:36 +0000 | |
| commit | a68686f9d77147fb034d6dea646b3fb9336faf2e (patch) | |
| tree | bf4f04868840a54c1c853bf961e5eae9db428f23 /backend/route.py | |
| parent | Add database middleware (diff) | |
Add route class and route manager for dynamic route loading
Diffstat (limited to '')
| -rw-r--r-- | backend/route.py | 17 | 
1 files changed, 17 insertions, 0 deletions
| diff --git a/backend/route.py b/backend/route.py new file mode 100644 index 0000000..af68b93 --- /dev/null +++ b/backend/route.py @@ -0,0 +1,17 @@ +""" +Base class for implementing dynamic routing. +""" +from starlette.endpoints import HTTPEndpoint + + +class Route(HTTPEndpoint): +    name: str = None +    path: str = None + +    @classmethod +    def check_parameters(cls): +        if cls.name is None: +            raise ValueError(f"Route {cls.__name__} has not defined a name") + +        if cls.path is None: +            raise ValueError(f"Route {cls.__name__} has not defined a path") | 
