Files
godoxy-yusing/internal/route/test_route.go
Yuzerion 31b4fedf72 refactor(entrypoint): move route registry into entrypoint context (#200)
- Introduced `NewTestRoute` function to simplify route creation in benchmark tests.
- Replaced direct route validation and starting with error handling using `require.NoError`.
- Updated server retrieval to use `common.ProxyHTTPAddr` for consistency.
- Improved logging for HTTP route addition errors in `AddRoute` method.

* fix(tcp): wrap proxy proto listener before acl

* refactor(entrypoint): propagate errors from route registration and stream serving

* fix(docs): correct swagger and package README
2026-02-08 09:17:46 +08:00

33 lines
617 B
Go

package route
import (
"testing"
"github.com/yusing/godoxy/internal/entrypoint"
epctx "github.com/yusing/godoxy/internal/entrypoint/types"
"github.com/yusing/godoxy/internal/types"
"github.com/yusing/goutils/task"
)
func NewStartedTestRoute(t testing.TB, base *Route) (types.Route, error) {
t.Helper()
task := task.GetTestTask(t)
if ep := epctx.FromCtx(task.Context()); ep == nil {
ep = entrypoint.NewEntrypoint(task, nil)
epctx.SetCtx(task, ep)
}
err := base.Validate()
if err != nil {
return nil, err
}
err = base.Start(task)
if err != nil {
return nil, err
}
return base.impl, nil
}