mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-21 08:39:03 +01:00
- 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
33 lines
617 B
Go
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
|
|
}
|