Skip to content

Commit

Permalink
Merge pull request #889 from hwcer/master
Browse files Browse the repository at this point in the history
批量更新router,更好的支持热更
  • Loading branch information
smallnest authored Jan 28, 2025
2 parents 675b720 + 474f0fa commit 48fd137
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server/router.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package server

// UpdateHandler 批量更新router
// 服务器使用plugin热更时,批量替换特定接口
func (s *Server) UpdateHandler(router map[string]Handler) {
newRouter := make(map[string]Handler)
for k, v := range s.router {
newRouter[k] = v
}
for k, v := range router {
newRouter[k] = v
}
s.router = newRouter
}

0 comments on commit 48fd137

Please sign in to comment.