refactor: rename module route/types to route

This commit is contained in:
yusing
2025-04-08 05:04:49 +08:00
parent 8ed63fe4b0
commit c59567ae8f
10 changed files with 74 additions and 69 deletions

View File

@@ -1,4 +1,4 @@
package types
package route
import (
"time"

View File

@@ -1,11 +1,11 @@
package types_test
package route_test
import (
"testing"
"time"
. "github.com/yusing/go-proxy/internal/route"
"github.com/yusing/go-proxy/internal/route/types"
route "github.com/yusing/go-proxy/internal/route/types"
"github.com/yusing/go-proxy/internal/utils"
. "github.com/yusing/go-proxy/internal/utils/testing"
)
@@ -14,14 +14,14 @@ func TestHTTPConfigDeserialize(t *testing.T) {
tests := []struct {
name string
input map[string]any
expected types.HTTPConfig
expected route.HTTPConfig
}{
{
name: "no_tls_verify",
input: map[string]any{
"no_tls_verify": "true",
},
expected: types.HTTPConfig{
expected: route.HTTPConfig{
NoTLSVerify: true,
},
},
@@ -30,7 +30,7 @@ func TestHTTPConfigDeserialize(t *testing.T) {
input: map[string]any{
"response_header_timeout": "1s",
},
expected: types.HTTPConfig{
expected: route.HTTPConfig{
ResponseHeaderTimeout: 1 * time.Second,
},
},

View File

@@ -1,4 +1,4 @@
package types
package route
import (
"strconv"
@@ -8,8 +8,8 @@ import (
)
type Port struct {
Listening int `json:"listening"`
Proxy int `json:"proxy"`
Listening int `json:"listening,omitempty"`
Proxy int `json:"proxy,omitempty"`
}
var (

View File

@@ -1,4 +1,4 @@
package types
package route
import (
"errors"

View File

@@ -1,4 +1,4 @@
package types
package route
import (
"net/http"
@@ -12,6 +12,7 @@ import (
"github.com/yusing/go-proxy/internal/watcher/health"
loadbalance "github.com/yusing/go-proxy/internal/net/gphttp/loadbalancer/types"
"github.com/yusing/go-proxy/internal/net/gphttp/reverseproxy"
)
type (
@@ -46,6 +47,10 @@ type (
Route
http.Handler
}
ReverseProxyRoute interface {
HTTPRoute
ReverseProxy() *reverseproxy.ReverseProxy
}
StreamRoute interface {
Route
net.Stream

View File

@@ -1,4 +1,4 @@
package types
package route
type RouteType string

View File

@@ -1,4 +1,4 @@
package types
package route
import (
"github.com/yusing/go-proxy/internal/gperr"