mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-05 00:17:03 +02:00
refactor(entrypoint): streamline benchmark tests and enhance error handling
- 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.
This commit is contained in:
22
internal/route/test_route.go
Normal file
22
internal/route/test_route.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"github.com/yusing/godoxy/internal/types"
|
||||
"github.com/yusing/goutils/task"
|
||||
)
|
||||
|
||||
func NewTestRoute[T interface{ Helper() }](t T, task task.Parent, base *Route) (types.Route, error) {
|
||||
t.Helper()
|
||||
|
||||
err := base.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = base.Start(task)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return base.impl, nil
|
||||
}
|
||||
Reference in New Issue
Block a user