From a68686f9d77147fb034d6dea646b3fb9336faf2e Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Sun, 25 Oct 2020 19:50:36 +0000 Subject: Add route class and route manager for dynamic route loading --- backend/route.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 backend/route.py (limited to 'backend/route.py') 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") -- cgit v1.2.3