mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-21 17:10:14 +01:00
refactor: minor issue and documentation
This commit is contained in:
@@ -377,7 +377,7 @@ Routes can access the entrypoint from request context:
|
||||
|
||||
```go
|
||||
// Set entrypoint in context
|
||||
entrypoint.SetCtx(r.Context(), ep)
|
||||
entrypoint.SetCtx(task, ep)
|
||||
|
||||
// Get entrypoint from context
|
||||
if ep := entrypoint.FromCtx(r.Context()); ep != nil {
|
||||
|
||||
@@ -230,7 +230,6 @@ func TestEntrypointBypassRoute(t *testing.T) {
|
||||
portInt, err := strconv.Atoi(port)
|
||||
expect.NoError(t, err)
|
||||
|
||||
expect.NoError(t, err)
|
||||
entry := entrypoint.NewTestEntrypoint(t, nil)
|
||||
_, err = route.NewStartedTestRoute(t, &route.Route{
|
||||
Alias: "test-route",
|
||||
|
||||
@@ -212,9 +212,9 @@ func TestRouteBindField(t *testing.T) {
|
||||
t.Run("HTTPSchemeWithoutBind", func(t *testing.T) {
|
||||
r := &Route{
|
||||
Alias: "test-http",
|
||||
Scheme: route.SchemeHTTPS,
|
||||
Scheme: route.SchemeHTTP,
|
||||
Host: "example.com",
|
||||
Port: route.Port{Proxy: 443},
|
||||
Port: route.Port{Proxy: 80},
|
||||
}
|
||||
err := r.Validate()
|
||||
require.NoError(t, err, "Validate should not return error for HTTP route with bind")
|
||||
@@ -225,9 +225,9 @@ func TestRouteBindField(t *testing.T) {
|
||||
t.Run("HTTPSchemeWithBind", func(t *testing.T) {
|
||||
r := &Route{
|
||||
Alias: "test-http",
|
||||
Scheme: route.SchemeHTTPS,
|
||||
Scheme: route.SchemeHTTP,
|
||||
Host: "example.com",
|
||||
Port: route.Port{Proxy: 443},
|
||||
Port: route.Port{Proxy: 80},
|
||||
Bind: "0.0.0.0",
|
||||
}
|
||||
err := r.Validate()
|
||||
@@ -239,15 +239,15 @@ func TestRouteBindField(t *testing.T) {
|
||||
t.Run("HTTPSchemeWithBindAndPort", func(t *testing.T) {
|
||||
r := &Route{
|
||||
Alias: "test-http",
|
||||
Scheme: route.SchemeHTTPS,
|
||||
Scheme: route.SchemeHTTP,
|
||||
Host: "example.com",
|
||||
Port: route.Port{Listening: 8443, Proxy: 443},
|
||||
Port: route.Port{Listening: 8080, Proxy: 80},
|
||||
Bind: "0.0.0.0",
|
||||
}
|
||||
err := r.Validate()
|
||||
require.NoError(t, err, "Validate should not return error for HTTP route with bind and port")
|
||||
require.NotNil(t, r.LisURL, "LisURL should be set")
|
||||
require.Equal(t, "https://0.0.0.0:8443", r.LisURL.String(), "LisURL should contain bind address and listening port")
|
||||
require.Equal(t, "https://0.0.0.0:8080", r.LisURL.String(), "LisURL should contain bind address and listening port")
|
||||
})
|
||||
|
||||
t.Run("TCPSchemeDefaultsToZeroBind", func(t *testing.T) {
|
||||
|
||||
@@ -63,10 +63,9 @@ func NewUDPUDPStream(network, listenAddr, dstAddr string) (nettypes.Stream, erro
|
||||
|
||||
```go
|
||||
type Stream interface {
|
||||
ListenAndServe(ctx context.Context, preDial, onRead HookFunc)
|
||||
ListenAndServe(ctx context.Context, preDial, onRead HookFunc) error
|
||||
Close() error
|
||||
LocalAddr() net.Addr
|
||||
zerolog.LogObjectMarshaler
|
||||
}
|
||||
|
||||
type HookFunc func(ctx context.Context) error
|
||||
|
||||
Reference in New Issue
Block a user