Skip to content

Commit eda83aa

Browse files
committed
docs: add RebuildTree to what's new documentation
1 parent 852b0e3 commit eda83aa

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/whats_new.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,31 @@ app.Route("/api").Route("/user/:id?")
389389
});
390390
```
391391

392+
### 🗺 RebuildTree
393+
394+
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
415+
development mode. Avoid using it concurrently.
416+
392417
### 🧠 Context
393418

394419
### 📎 Parser

0 commit comments

Comments
 (0)