You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Custom routers can be used to define custom routing logic for your application. This is useful when you need to implement a custom routing algorithm or when you need to integrate with an existing URL routing system.
2
2
3
-
Under construction 🚧
3
+
---
4
+
5
+
## Step 1: Creating a custom resolver
6
+
7
+
You may want to create a custom resolver to allow ReactPy to utilize an existing routing syntax.
8
+
9
+
To start off, you will need to create a subclass of `#!python ReactPyResolver`. Within this subclass, you have two attributes which you can modify to support your custom routing syntax:
10
+
11
+
-`#!python param_pattern`: A regular expression pattern that matches the parameters in your URL. This pattern must contain the regex named groups `name` and `type`.
12
+
-`#!python converters`: A dictionary that maps a `type` to it's respective `regex` pattern and a converter `func`.
13
+
14
+
=== "resolver.py"
15
+
16
+
```python
17
+
{% include "../../examples/python/custom_router_easy_resolver.py" %}
18
+
```
19
+
20
+
## Step 2: Creating a custom router
21
+
22
+
Then, you can use this resolver to create your custom router...
23
+
24
+
=== "resolver.py"
25
+
26
+
```python
27
+
{% include "../../examples/python/custom_router_easy_router.py" %}
0 commit comments