mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-21 08:42:16 +08:00
add Engine.ResetRoutes() for clean existed routes
Signed-off-by: tsaikd <tsaikd@gmail.com>
This commit is contained in:
parent
8ee9d959a0
commit
b89135957d
5
gin.go
5
gin.go
@ -283,6 +283,11 @@ func iterate(path, method string, routes RoutesInfo, root *node) RoutesInfo {
|
||||
return routes
|
||||
}
|
||||
|
||||
// ResetRoutes reset routes in Engine, used when application need to change routes dynamically
|
||||
func (engine *Engine) ResetRoutes() {
|
||||
engine.trees = make(methodTrees, 0, 9)
|
||||
}
|
||||
|
||||
// Run attaches the router to a http.Server and starts listening and serving HTTP requests.
|
||||
// It is a shortcut for http.ListenAndServe(addr, router)
|
||||
// Note: this method will block the calling goroutine indefinitely unless an error happens.
|
||||
|
Loading…
x
Reference in New Issue
Block a user