mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-20 07:21:26 +02:00
refactor: move task, error and testing utils to separte repo; apply gofumpt
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
"github.com/yusing/godoxy/internal/route/routes"
|
||||
"github.com/yusing/godoxy/internal/types"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
)
|
||||
|
||||
func checkExists(r types.Route) gperr.Error {
|
||||
|
||||
@@ -5,13 +5,13 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
"github.com/yusing/godoxy/internal/logging/accesslog"
|
||||
gphttp "github.com/yusing/godoxy/internal/net/gphttp"
|
||||
"github.com/yusing/godoxy/internal/net/gphttp/middleware"
|
||||
"github.com/yusing/godoxy/internal/route/routes"
|
||||
"github.com/yusing/godoxy/internal/task"
|
||||
"github.com/yusing/godoxy/internal/watcher/health/monitor"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
"github.com/yusing/goutils/task"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
@@ -10,26 +10,26 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
. "github.com/yusing/godoxy/internal/utils/testing"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
)
|
||||
|
||||
func TestPathTraversalAttack(t *testing.T) {
|
||||
tmp := t.TempDir()
|
||||
root := filepath.Join(tmp, "static")
|
||||
if err := os.Mkdir(root, 0755); err != nil {
|
||||
if err := os.Mkdir(root, 0o755); err != nil {
|
||||
t.Fatalf("Failed to create root directory: %v", err)
|
||||
}
|
||||
|
||||
// Create a file inside the root
|
||||
validPath := "test.txt"
|
||||
validContent := "test content"
|
||||
if err := os.WriteFile(filepath.Join(root, validPath), []byte(validContent), 0644); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(root, validPath), []byte(validContent), 0o644); err != nil {
|
||||
t.Fatalf("Failed to create test file: %v", err)
|
||||
}
|
||||
|
||||
// create one at ..
|
||||
secretFile := "secret.txt"
|
||||
if err := os.WriteFile(filepath.Join(tmp, secretFile), []byte(validContent), 0644); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(tmp, secretFile), []byte(validContent), 0o644); err != nil {
|
||||
t.Fatalf("Failed to create test file: %v", err)
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ func TestPathTraversalAttack(t *testing.T) {
|
||||
t.Errorf("Expected status 404 or 400, got %d in url %s", resp.StatusCode, u.String())
|
||||
}
|
||||
|
||||
u = Must(url.Parse(ts.URL + "/" + p))
|
||||
u = expect.Must(url.Parse(ts.URL + "/" + p))
|
||||
resp, err = http.DefaultClient.Do(&http.Request{
|
||||
Method: http.MethodGet,
|
||||
URL: u,
|
||||
|
||||
@@ -67,7 +67,7 @@ func getSchemePortByImageName(imageName string) (scheme string, port int, ok boo
|
||||
if port, ok := ImageNamePortMapTCP[imageName]; ok {
|
||||
return "tcp", port, true
|
||||
}
|
||||
return
|
||||
return scheme, port, ok
|
||||
}
|
||||
|
||||
func getSchemePortByAlias(alias string) (scheme string, port int, ok bool) {
|
||||
@@ -77,5 +77,5 @@ func getSchemePortByAlias(alias string) (scheme string, port int, ok bool) {
|
||||
if port, ok := AliasPortMapHTTPS[alias]; ok {
|
||||
return "https", port, true
|
||||
}
|
||||
return
|
||||
return scheme, port, ok
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package provider
|
||||
import (
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/yusing/godoxy/agent/pkg/agent"
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
"github.com/yusing/godoxy/internal/route"
|
||||
"github.com/yusing/godoxy/internal/watcher"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
)
|
||||
|
||||
type AgentProvider struct {
|
||||
|
||||
@@ -10,11 +10,11 @@ import (
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/yusing/godoxy/internal/docker"
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
"github.com/yusing/godoxy/internal/route"
|
||||
"github.com/yusing/godoxy/internal/serialization"
|
||||
"github.com/yusing/godoxy/internal/types"
|
||||
"github.com/yusing/godoxy/internal/watcher"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
)
|
||||
|
||||
type DockerProvider struct {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/goccy/go-yaml"
|
||||
"github.com/yusing/godoxy/internal/docker"
|
||||
. "github.com/yusing/godoxy/internal/utils/testing"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
|
||||
_ "embed"
|
||||
)
|
||||
@@ -18,7 +18,7 @@ func TestParseDockerLabels(t *testing.T) {
|
||||
var provider DockerProvider
|
||||
|
||||
labels := make(map[string]string)
|
||||
ExpectNoError(t, yaml.Unmarshal(testDockerLabelsYAML, &labels))
|
||||
expect.NoError(t, yaml.Unmarshal(testDockerLabelsYAML, &labels))
|
||||
|
||||
routes, err := provider.routesFromContainerLabels(
|
||||
docker.FromDocker(&container.Summary{
|
||||
@@ -30,7 +30,7 @@ func TestParseDockerLabels(t *testing.T) {
|
||||
},
|
||||
}, "/var/run/docker.sock"),
|
||||
)
|
||||
ExpectNoError(t, err)
|
||||
ExpectTrue(t, routes.Contains("app"))
|
||||
ExpectTrue(t, routes.Contains("app1"))
|
||||
expect.NoError(t, err)
|
||||
expect.True(t, routes.Contains("app"))
|
||||
expect.True(t, routes.Contains("app1"))
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
D "github.com/yusing/godoxy/internal/docker"
|
||||
"github.com/yusing/godoxy/internal/route"
|
||||
T "github.com/yusing/godoxy/internal/route/types"
|
||||
expect "github.com/yusing/godoxy/internal/utils/testing"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
)
|
||||
|
||||
var dummyNames = []string{"/a"}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
"github.com/yusing/godoxy/internal/route"
|
||||
provider "github.com/yusing/godoxy/internal/route/provider/types"
|
||||
"github.com/yusing/godoxy/internal/task"
|
||||
"github.com/yusing/godoxy/internal/watcher"
|
||||
eventsPkg "github.com/yusing/godoxy/internal/watcher/events"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
"github.com/yusing/goutils/task"
|
||||
)
|
||||
|
||||
type EventHandler struct {
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/yusing/godoxy/internal/common"
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
"github.com/yusing/godoxy/internal/route"
|
||||
"github.com/yusing/godoxy/internal/serialization"
|
||||
W "github.com/yusing/godoxy/internal/watcher"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
)
|
||||
|
||||
type FileProvider struct {
|
||||
@@ -44,12 +44,12 @@ func removeXPrefix(m map[string]any) gperr.Error {
|
||||
|
||||
func validate(data []byte) (routes route.Routes, err gperr.Error) {
|
||||
err = serialization.UnmarshalValidateYAMLIntercept(data, &routes, removeXPrefix)
|
||||
return
|
||||
return routes, err
|
||||
}
|
||||
|
||||
func Validate(data []byte) (err gperr.Error) {
|
||||
_, err = validate(data)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *FileProvider) String() string {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
|
||||
_ "embed"
|
||||
|
||||
. "github.com/yusing/godoxy/internal/utils/testing"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
)
|
||||
|
||||
//go:embed all_fields.yaml
|
||||
@@ -13,5 +13,5 @@ var testAllFieldsYAML []byte
|
||||
|
||||
func TestFile(t *testing.T) {
|
||||
_, err := validate(testAllFieldsYAML)
|
||||
ExpectNoError(t, err)
|
||||
expect.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -13,14 +13,14 @@ import (
|
||||
"github.com/yusing/godoxy/agent/pkg/agent"
|
||||
"github.com/yusing/godoxy/internal/common"
|
||||
"github.com/yusing/godoxy/internal/docker"
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
"github.com/yusing/godoxy/internal/route"
|
||||
provider "github.com/yusing/godoxy/internal/route/provider/types"
|
||||
"github.com/yusing/godoxy/internal/task"
|
||||
"github.com/yusing/godoxy/internal/types"
|
||||
W "github.com/yusing/godoxy/internal/watcher"
|
||||
"github.com/yusing/godoxy/internal/watcher/events"
|
||||
"github.com/yusing/goutils/env"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
"github.com/yusing/goutils/task"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -66,7 +66,7 @@ func NewFileProvider(filename string) (p *Provider, err error) {
|
||||
return nil, err
|
||||
}
|
||||
p.watcher = p.NewWatcher()
|
||||
return
|
||||
return p, err
|
||||
}
|
||||
|
||||
func NewDockerProvider(name string, dockerHost string) *Provider {
|
||||
@@ -146,7 +146,7 @@ func (p *Provider) Start(parent task.Parent) gperr.Error {
|
||||
|
||||
func (p *Provider) LoadRoutes() (err gperr.Error) {
|
||||
p.routes, err = p.loadRoutes()
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *Provider) NumRoutes() int {
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/yusing/godoxy/agent/pkg/agent"
|
||||
"github.com/yusing/godoxy/agent/pkg/agentproxy"
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
"github.com/yusing/godoxy/internal/homepage"
|
||||
"github.com/yusing/godoxy/internal/idlewatcher"
|
||||
"github.com/yusing/godoxy/internal/logging/accesslog"
|
||||
@@ -15,11 +14,12 @@ import (
|
||||
"github.com/yusing/godoxy/internal/net/gphttp/middleware"
|
||||
nettypes "github.com/yusing/godoxy/internal/net/types"
|
||||
"github.com/yusing/godoxy/internal/route/routes"
|
||||
"github.com/yusing/godoxy/internal/task"
|
||||
"github.com/yusing/godoxy/internal/types"
|
||||
"github.com/yusing/godoxy/internal/watcher/health/monitor"
|
||||
"github.com/yusing/godoxy/pkg"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
"github.com/yusing/goutils/http/reverseproxy"
|
||||
"github.com/yusing/goutils/task"
|
||||
)
|
||||
|
||||
type ReveseProxyRoute struct {
|
||||
|
||||
@@ -12,14 +12,14 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/yusing/godoxy/agent/pkg/agent"
|
||||
"github.com/yusing/godoxy/internal/docker"
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
"github.com/yusing/godoxy/internal/homepage"
|
||||
netutils "github.com/yusing/godoxy/internal/net"
|
||||
nettypes "github.com/yusing/godoxy/internal/net/types"
|
||||
"github.com/yusing/godoxy/internal/proxmox"
|
||||
"github.com/yusing/godoxy/internal/task"
|
||||
"github.com/yusing/godoxy/internal/types"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
"github.com/yusing/goutils/task"
|
||||
|
||||
"github.com/yusing/godoxy/internal/common"
|
||||
config "github.com/yusing/godoxy/internal/config/types"
|
||||
@@ -721,5 +721,5 @@ func preferredPort(portMapping map[int]container.Port) (res int) {
|
||||
res = port
|
||||
}
|
||||
}
|
||||
return
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/yusing/godoxy/internal/common"
|
||||
route "github.com/yusing/godoxy/internal/route/types"
|
||||
"github.com/yusing/godoxy/internal/types"
|
||||
expect "github.com/yusing/godoxy/internal/utils/testing"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
)
|
||||
|
||||
func TestRouteValidate(t *testing.T) {
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
gphttp "github.com/yusing/godoxy/internal/net/gphttp"
|
||||
nettypes "github.com/yusing/godoxy/internal/net/types"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
"github.com/yusing/goutils/http/reverseproxy"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ package rules
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/yusing/godoxy/internal/utils/testing"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
)
|
||||
|
||||
func TestParseCommands(t *testing.T) {
|
||||
@@ -131,9 +131,9 @@ func TestParseCommands(t *testing.T) {
|
||||
cmd := Command{}
|
||||
err := cmd.Parse(tt.input)
|
||||
if tt.wantErr != nil {
|
||||
ExpectError(t, tt.wantErr, err)
|
||||
expect.ErrorIs(t, tt.wantErr, err)
|
||||
} else {
|
||||
ExpectNoError(t, err)
|
||||
expect.NoError(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -2,14 +2,13 @@ package rules
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"slices"
|
||||
|
||||
"github.com/gobwas/glob"
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
nettypes "github.com/yusing/godoxy/internal/net/types"
|
||||
"github.com/yusing/godoxy/internal/route/routes"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
)
|
||||
|
||||
@@ -248,8 +247,10 @@ var checkers = map[string]struct {
|
||||
},
|
||||
}
|
||||
|
||||
var asciiSpace = [256]uint8{'\t': 1, '\n': 1, '\v': 1, '\f': 1, '\r': 1, ' ': 1}
|
||||
var andSeps = [256]uint8{'&': 1, '\n': 1}
|
||||
var (
|
||||
asciiSpace = [256]uint8{'\t': 1, '\n': 1, '\v': 1, '\f': 1, '\r': 1, ' ': 1}
|
||||
andSeps = [256]uint8{'&': 1, '\n': 1}
|
||||
)
|
||||
|
||||
func indexAnd(s string) int {
|
||||
for i, c := range s {
|
||||
|
||||
@@ -3,8 +3,8 @@ package rules
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
expect "github.com/yusing/godoxy/internal/utils/testing"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
)
|
||||
|
||||
func TestSplitAnd(t *testing.T) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/yusing/godoxy/internal/route"
|
||||
"github.com/yusing/godoxy/internal/route/routes"
|
||||
. "github.com/yusing/godoxy/internal/route/rules"
|
||||
expect "github.com/yusing/godoxy/internal/utils/testing"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"unicode"
|
||||
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
)
|
||||
|
||||
var escapedChars = map[rune]rune{
|
||||
@@ -57,7 +57,7 @@ func parse(v string) (subject string, args []string, err gperr.Error) {
|
||||
buf.WriteRune(ch)
|
||||
} else {
|
||||
err = ErrUnsupportedEscapeChar.Subjectf("\\%c", r)
|
||||
return
|
||||
return subject, args, err
|
||||
}
|
||||
escaped = false
|
||||
continue
|
||||
@@ -93,5 +93,5 @@ func parse(v string) (subject string, args []string, err gperr.Error) {
|
||||
} else {
|
||||
flush(false)
|
||||
}
|
||||
return
|
||||
return subject, args, err
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
. "github.com/yusing/godoxy/internal/utils/testing"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
)
|
||||
|
||||
func TestParser(t *testing.T) {
|
||||
@@ -68,15 +68,15 @@ func TestParser(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
subject, args, err := parse(tt.input)
|
||||
if tt.wantErr != nil {
|
||||
ExpectError(t, tt.wantErr, err)
|
||||
expect.ErrorIs(t, tt.wantErr, err)
|
||||
return
|
||||
}
|
||||
// t.Log(subject, args, err)
|
||||
ExpectNoError(t, err)
|
||||
ExpectEqual(t, subject, tt.subject)
|
||||
ExpectEqual(t, len(args), len(tt.args))
|
||||
expect.NoError(t, err)
|
||||
expect.Equal(t, subject, tt.subject)
|
||||
expect.Equal(t, len(args), len(tt.args))
|
||||
for i, arg := range args {
|
||||
ExpectEqual(t, arg, tt.args[i])
|
||||
expect.Equal(t, arg, tt.args[i])
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -89,7 +89,7 @@ func TestParser(t *testing.T) {
|
||||
for i, test := range tests {
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
_, _, err := parse(test)
|
||||
ExpectError(t, ErrUnterminatedQuotes, err)
|
||||
expect.ErrorIs(t, ErrUnterminatedQuotes, err)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -130,5 +130,5 @@ func (rule *Rule) Check(cached Cache, r *http.Request) bool {
|
||||
|
||||
func (rule *Rule) Handle(cached Cache, w http.ResponseWriter, r *http.Request) (proceed bool) {
|
||||
proceed = rule.Do.exec.Handle(cached, w, r)
|
||||
return
|
||||
return proceed
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/yusing/godoxy/internal/serialization"
|
||||
. "github.com/yusing/godoxy/internal/utils/testing"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
)
|
||||
|
||||
func TestParseRule(t *testing.T) {
|
||||
@@ -29,18 +29,18 @@ func TestParseRule(t *testing.T) {
|
||||
Rules Rules
|
||||
}
|
||||
err := serialization.MapUnmarshalValidate(serialization.SerializedObject{"rules": test}, &rules)
|
||||
ExpectNoError(t, err)
|
||||
ExpectEqual(t, len(rules.Rules), len(test))
|
||||
ExpectEqual(t, rules.Rules[0].Name, "test")
|
||||
ExpectEqual(t, rules.Rules[0].On.String(), "method POST")
|
||||
ExpectEqual(t, rules.Rules[0].Do.String(), "error 403 Forbidden")
|
||||
expect.NoError(t, err)
|
||||
expect.Equal(t, len(rules.Rules), len(test))
|
||||
expect.Equal(t, rules.Rules[0].Name, "test")
|
||||
expect.Equal(t, rules.Rules[0].On.String(), "method POST")
|
||||
expect.Equal(t, rules.Rules[0].Do.String(), "error 403 Forbidden")
|
||||
|
||||
ExpectEqual(t, rules.Rules[1].Name, "auth")
|
||||
ExpectEqual(t, rules.Rules[1].On.String(), `basic_auth "username" "password" | basic_auth username2 "password2" | basic_auth "username3" "password3"`)
|
||||
ExpectEqual(t, rules.Rules[1].Do.String(), "bypass")
|
||||
expect.Equal(t, rules.Rules[1].Name, "auth")
|
||||
expect.Equal(t, rules.Rules[1].On.String(), `basic_auth "username" "password" | basic_auth username2 "password2" | basic_auth "username3" "password3"`)
|
||||
expect.Equal(t, rules.Rules[1].Do.String(), "bypass")
|
||||
|
||||
ExpectEqual(t, rules.Rules[2].Name, "default")
|
||||
ExpectEqual(t, rules.Rules[2].Do.String(), "require_basic_auth any_realm")
|
||||
expect.Equal(t, rules.Rules[2].Name, "default")
|
||||
expect.Equal(t, rules.Rules[2].Do.String(), "require_basic_auth any_realm")
|
||||
}
|
||||
|
||||
// TODO: real tests.
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/gobwas/glob"
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
gphttp "github.com/yusing/godoxy/internal/net/gphttp"
|
||||
nettypes "github.com/yusing/godoxy/internal/net/types"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
@@ -7,14 +7,14 @@ import (
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
"github.com/yusing/godoxy/internal/idlewatcher"
|
||||
nettypes "github.com/yusing/godoxy/internal/net/types"
|
||||
"github.com/yusing/godoxy/internal/route/routes"
|
||||
"github.com/yusing/godoxy/internal/route/stream"
|
||||
"github.com/yusing/godoxy/internal/task"
|
||||
"github.com/yusing/godoxy/internal/types"
|
||||
"github.com/yusing/godoxy/internal/watcher/health/monitor"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
"github.com/yusing/goutils/task"
|
||||
)
|
||||
|
||||
// TODO: support stream load balance.
|
||||
|
||||
@@ -168,12 +168,12 @@ type wrapperConn struct {
|
||||
func (w *wrapperConn) Read(b []byte) (n int, err error) {
|
||||
n, err = w.Conn.Read(b)
|
||||
if err != nil {
|
||||
return
|
||||
return n, err
|
||||
}
|
||||
if w.onRead != nil {
|
||||
if err = w.onRead(w.ctx); err != nil {
|
||||
return
|
||||
return n, err
|
||||
}
|
||||
}
|
||||
return
|
||||
return n, err
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
)
|
||||
|
||||
type HTTPConfig struct {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
. "github.com/yusing/godoxy/internal/route"
|
||||
route "github.com/yusing/godoxy/internal/route/types"
|
||||
"github.com/yusing/godoxy/internal/serialization"
|
||||
expect "github.com/yusing/godoxy/internal/utils/testing"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
)
|
||||
|
||||
func TestHTTPConfigDeserialize(t *testing.T) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package route
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
)
|
||||
|
||||
type Scheme string
|
||||
|
||||
Reference in New Issue
Block a user