mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-18 15:23:51 +01:00
24 lines
524 B
Go
24 lines
524 B
Go
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
|
|
}
|