feat(healthcheck): allow health checking for excluded routes

This commit is contained in:
yusing
2025-06-02 23:19:30 +08:00
parent 4705989f4b
commit 9087c4f195
9 changed files with 138 additions and 57 deletions

23
internal/route/common.go Normal file
View File

@@ -0,0 +1,23 @@
package route
import (
"github.com/yusing/go-proxy/internal/gperr"
"github.com/yusing/go-proxy/internal/route/routes"
)
func checkExists(r routes.Route) gperr.Error {
var (
existing routes.Route
ok bool
)
switch r := r.(type) {
case routes.HTTPRoute:
existing, ok = routes.HTTP.Get(r.Key())
case routes.StreamRoute:
existing, ok = routes.Stream.Get(r.Key())
}
if ok {
return gperr.Errorf("route already exists: from provider %s and %s", existing.ProviderName(), r.ProviderName())
}
return nil
}