From b89135957dac8543a7453f867734d9beacf4a3f8 Mon Sep 17 00:00:00 2001 From: tsaikd Date: Thu, 19 May 2016 14:18:49 +0800 Subject: [PATCH] add Engine.ResetRoutes() for clean existed routes Signed-off-by: tsaikd --- gin.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gin.go b/gin.go index 4dbe9836..38a7719f 100644 --- a/gin.go +++ b/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.