mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 08:48:32 +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:
@@ -30,9 +30,11 @@ Internal package with stable core types. Route configuration schema is versioned
|
||||
type Route struct {
|
||||
Alias string // Unique route identifier
|
||||
Scheme Scheme // http, https, h2c, tcp, udp, fileserver
|
||||
Host string // Virtual host
|
||||
Host string // Target host
|
||||
Port Port // Listen and target ports
|
||||
|
||||
Bind string // Bind address for listening (IP address, optional)
|
||||
|
||||
// File serving
|
||||
Root string // Document root
|
||||
SPA bool // Single-page app mode
|
||||
@@ -196,6 +198,7 @@ type Route struct {
|
||||
Alias string `json:"alias"`
|
||||
Scheme Scheme `json:"scheme"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Bind string `json:"bind,omitempty"` // Listen bind address
|
||||
Port Port `json:"port"`
|
||||
Root string `json:"root,omitempty"`
|
||||
SPA bool `json:"spa,omitempty"`
|
||||
@@ -218,23 +221,26 @@ labels:
|
||||
routes:
|
||||
myapp:
|
||||
scheme: http
|
||||
root: /var/www/myapp
|
||||
spa: true
|
||||
host: myapp.local
|
||||
bind: 192.168.1.100 # Optional: bind to specific address
|
||||
port:
|
||||
proxy: 80
|
||||
target: 3000
|
||||
```
|
||||
|
||||
## Dependency and Integration Map
|
||||
|
||||
| Dependency | Purpose |
|
||||
| -------------------------------- | -------------------------------- |
|
||||
| `internal/route/routes` | Route registry and lookup |
|
||||
| `internal/route/rules` | Request/response rule processing |
|
||||
| `internal/route/stream` | TCP/UDP stream proxying |
|
||||
| `internal/route/provider` | Route discovery and loading |
|
||||
| `internal/health/monitor` | Health checking |
|
||||
| `internal/idlewatcher` | Idle container management |
|
||||
| `internal/logging/accesslog` | Request logging |
|
||||
| `internal/homepage` | Dashboard integration |
|
||||
| `github.com/yusing/goutils/errs` | Error handling |
|
||||
| Dependency | Purpose |
|
||||
| ---------------------------------- | --------------------------------- |
|
||||
| `internal/route/routes/context.go` | Route context helpers (only file) |
|
||||
| `internal/route/rules` | Request/response rule processing |
|
||||
| `internal/route/stream` | TCP/UDP stream proxying |
|
||||
| `internal/route/provider` | Route discovery and loading |
|
||||
| `internal/health/monitor` | Health checking |
|
||||
| `internal/idlewatcher` | Idle container management |
|
||||
| `internal/logging/accesslog` | Request logging |
|
||||
| `internal/homepage` | Dashboard integration |
|
||||
| `github.com/yusing/goutils/errs` | Error handling |
|
||||
|
||||
## Observability
|
||||
|
||||
@@ -305,6 +311,18 @@ route := &route.Route{
|
||||
}
|
||||
```
|
||||
|
||||
### Route with Custom Bind Address
|
||||
|
||||
```go
|
||||
route := &route.Route{
|
||||
Alias: "myapp",
|
||||
Scheme: route.SchemeHTTP,
|
||||
Host: "myapp.local",
|
||||
Bind: "192.168.1.100", // Bind to specific interface
|
||||
Port: route.Port{Listening: 8443, Proxy: 80},
|
||||
}
|
||||
```
|
||||
|
||||
### File Server Route
|
||||
|
||||
```go
|
||||
|
||||
Reference in New Issue
Block a user