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
We have added a new method that allows the route tree stack to be rebuilt in runtime, with it you can add a route while your application is running and rebuild the route tree stack to make it registered and available for calls.
395
+
396
+
You can find more reference on it in the [app](./api/app.md#rebuildtree):
397
+
398
+
#### Example Usage
399
+
400
+
```go
401
+
app.Get("/define", func(c Ctx) error { // Define a new route dynamically
402
+
app.Get("/dynamically-defined", func(c Ctx) error { // Adding a dynamically defined route
403
+
return c.SendStatus(http.StatusOK)
404
+
})
405
+
406
+
app.RebuildTree() // Rebuild the route tree to register the new route
407
+
408
+
return c.SendStatus(http.StatusOK)
409
+
})
410
+
```
411
+
412
+
In this example, a new route is defined and then `RebuildTree()` is called to make sure the new route is registered and available.
413
+
414
+
**Note:** Use this method with caution. It is **not** thread-safe and calling it can be very performance-intensive, so it should be used sparingly and only in
0 commit comments