mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 17:28:31 +02:00
modules reorganized and code refactor
This commit is contained in:
7
internal/route/routes/metrics.go
Normal file
7
internal/route/routes/metrics.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package routes
|
||||
|
||||
import "github.com/yusing/go-proxy/internal/metrics"
|
||||
|
||||
func init() {
|
||||
metrics.InitRouterMetrics(httpRoutes.Size, streamRoutes.Size)
|
||||
}
|
||||
43
internal/route/routes/routes.go
Normal file
43
internal/route/routes/routes.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/yusing/go-proxy/internal/route/types"
|
||||
F "github.com/yusing/go-proxy/internal/utils/functional"
|
||||
)
|
||||
|
||||
var (
|
||||
httpRoutes = F.NewMapOf[string, types.HTTPRoute]()
|
||||
streamRoutes = F.NewMapOf[string, types.StreamRoute]()
|
||||
)
|
||||
|
||||
func GetHTTPRoutes() F.Map[string, types.HTTPRoute] {
|
||||
return httpRoutes
|
||||
}
|
||||
|
||||
func GetStreamRoutes() F.Map[string, types.StreamRoute] {
|
||||
return streamRoutes
|
||||
}
|
||||
|
||||
func GetHTTPRoute(alias string) (types.HTTPRoute, bool) {
|
||||
return httpRoutes.Load(alias)
|
||||
}
|
||||
|
||||
func GetStreamRoute(alias string) (types.StreamRoute, bool) {
|
||||
return streamRoutes.Load(alias)
|
||||
}
|
||||
|
||||
func SetHTTPRoute(alias string, r types.HTTPRoute) {
|
||||
httpRoutes.Store(alias, r)
|
||||
}
|
||||
|
||||
func SetStreamRoute(alias string, r types.StreamRoute) {
|
||||
streamRoutes.Store(alias, r)
|
||||
}
|
||||
|
||||
func DeleteHTTPRoute(alias string) {
|
||||
httpRoutes.Delete(alias)
|
||||
}
|
||||
|
||||
func DeleteStreamRoute(alias string) {
|
||||
streamRoutes.Delete(alias)
|
||||
}
|
||||
Reference in New Issue
Block a user