aboutsummaryrefslogtreecommitdiffstats
path: root/backend/route.py
blob: a9ea7ad5d828b438546f9de73040dceb887473b4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""Base class for implementing dynamic routing."""

from starlette.endpoints import HTTPEndpoint


class Route(HTTPEndpoint):
    name: str
    path: str

    @classmethod
    def check_parameters(cls) -> None:
        if not hasattr(cls, "name"):
            msg = f"Route {cls.__name__} has not defined a name"
            raise ValueError(msg)

        if not hasattr(cls, "path"):
            msg = f"Route {cls.__name__} has not defined a path"
            raise ValueError(msg)