preparing for v0.5

This commit is contained in:
default
2024-08-01 10:06:42 +08:00
parent 24778d1093
commit 93359110a2
115 changed files with 5153 additions and 4395 deletions

34
src/route/route.go Executable file
View File

@@ -0,0 +1,34 @@
package route
import (
E "github.com/yusing/go-proxy/error"
M "github.com/yusing/go-proxy/models"
P "github.com/yusing/go-proxy/proxy"
F "github.com/yusing/go-proxy/utils/functional"
)
type (
Route interface {
Start() E.NestedError
Stop() E.NestedError
}
Routes = F.Map[string, Route]
)
// function alias
var NewRoutes = F.NewMap[string, Route]
func NewRoute(en *M.ProxyEntry) (Route, E.NestedError) {
entry, err := P.NewEntry(en)
if err.IsNotNil() {
return nil, err
}
switch e := entry.(type) {
case *P.StreamEntry:
return NewStreamRoute(e)
case *P.Entry:
return NewHTTPRoute(e)
default:
panic("bug: should not reach here")
}
}