mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-08-24 02:52:32 +00:00
22 lines
380 B
Go
22 lines
380 B
Go
|
package route
|
||
|
|
||
|
import "github.com/go-chi/chi/v5"
|
||
|
|
||
|
type externalRouter func(r chi.Router)
|
||
|
|
||
|
var externalRouters = make([]externalRouter, 0)
|
||
|
|
||
|
func Register(route ...externalRouter) {
|
||
|
externalRouters = append(externalRouters, route...)
|
||
|
}
|
||
|
|
||
|
func addExternalRouters(r chi.Router) {
|
||
|
if len(externalRouters) == 0 {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
for _, caller := range externalRouters {
|
||
|
caller(r)
|
||
|
}
|
||
|
}
|