route.py
Provides route class.
Route
dataclass
Represents a single route mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
Route endpoint. Can contain optional path parameters with converter names. |
required |
handler
|
Callable
|
Request handler. |
required |
methods
|
Iterable[str]
|
Allowed request methods. |
required |
Source code in jetweb/routing/route.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
match_endpoint(endpoint)
Match a request endpoint against this route's pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
Request endpoint for matching. |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, dict]
|
True if endpoint is matched and parsed path parameters. |
Source code in jetweb/routing/route.py
33 34 35 36 37 38 39 40 41 42 43 | |
match_method(method)
Match a request method against this route's allowed methods.
Returns:
| Type | Description |
|---|---|
bool
|
True if method is matched. |
Source code in jetweb/routing/route.py
45 46 47 48 49 50 51 | |