mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 00:38:33 +02:00
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
This commit is contained in:
39
internal/route/reverse_proxy_test.go
Normal file
39
internal/route/reverse_proxy_test.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
route "github.com/yusing/godoxy/internal/route/types"
|
||||
"github.com/yusing/godoxy/internal/types"
|
||||
)
|
||||
|
||||
func TestReverseProxyRoute(t *testing.T) {
|
||||
t.Run("LinkToLoadBalancer", func(t *testing.T) {
|
||||
cfg := Route{
|
||||
Alias: "test",
|
||||
Scheme: route.SchemeHTTP,
|
||||
Host: "example.com",
|
||||
Port: Port{Proxy: 80},
|
||||
LoadBalance: &types.LoadBalancerConfig{
|
||||
Link: "test",
|
||||
},
|
||||
}
|
||||
cfg1 := Route{
|
||||
Alias: "test1",
|
||||
Scheme: route.SchemeHTTP,
|
||||
Host: "example.com",
|
||||
Port: Port{Proxy: 80},
|
||||
LoadBalance: &types.LoadBalancerConfig{
|
||||
Link: "test",
|
||||
},
|
||||
}
|
||||
r, err := NewStartedTestRoute(t, &cfg)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, r)
|
||||
r2, err := NewStartedTestRoute(t, &cfg1)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, r2)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user