mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 09:18:51 +02:00
refactor(api): restructured API for type safety, maintainability and docs generation
- These changes makes the API incombatible with previous versions - Added new types for error handling, success responses, and health checks. - Updated health check logic to utilize the new types for better clarity and structure. - Refactored existing handlers to improve response consistency and error handling. - Updated Makefile to include a new target for generating API types from Swagger. - Updated "new agent" API to respond an encrypted cert pair
This commit is contained in:
@@ -5,11 +5,9 @@ import (
|
||||
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/yusing/go-proxy/internal/common"
|
||||
"github.com/yusing/go-proxy/internal/docker"
|
||||
loadbalance "github.com/yusing/go-proxy/internal/net/gphttp/loadbalancer/types"
|
||||
route "github.com/yusing/go-proxy/internal/route/types"
|
||||
"github.com/yusing/go-proxy/internal/types"
|
||||
expect "github.com/yusing/go-proxy/internal/utils/testing"
|
||||
"github.com/yusing/go-proxy/internal/watcher/health"
|
||||
)
|
||||
|
||||
func TestRouteValidate(t *testing.T) {
|
||||
@@ -43,10 +41,10 @@ func TestRouteValidate(t *testing.T) {
|
||||
Scheme: route.SchemeHTTP,
|
||||
Host: "example.com",
|
||||
Port: route.Port{Proxy: 80},
|
||||
HealthCheck: &health.HealthCheckConfig{
|
||||
HealthCheck: &types.HealthCheckConfig{
|
||||
Disable: true,
|
||||
},
|
||||
LoadBalance: &loadbalance.Config{
|
||||
LoadBalance: &types.LoadBalancerConfig{
|
||||
Link: "test-link",
|
||||
}, // Minimal LoadBalance config with non-empty Link will be checked by UseLoadBalance
|
||||
}
|
||||
@@ -99,9 +97,9 @@ func TestRouteValidate(t *testing.T) {
|
||||
Host: "example.com",
|
||||
Port: route.Port{Proxy: 80},
|
||||
Metadata: Metadata{
|
||||
Container: &docker.Container{
|
||||
Container: &types.Container{
|
||||
ContainerID: "test-id",
|
||||
Image: &docker.ContainerImage{
|
||||
Image: &types.ContainerImage{
|
||||
Name: "test-image",
|
||||
},
|
||||
},
|
||||
@@ -157,9 +155,9 @@ func TestDockerRouteDisallowAgent(t *testing.T) {
|
||||
Port: route.Port{Proxy: 80},
|
||||
Agent: "test-agent",
|
||||
Metadata: Metadata{
|
||||
Container: &docker.Container{
|
||||
Container: &types.Container{
|
||||
ContainerID: "test-id",
|
||||
Image: &docker.ContainerImage{
|
||||
Image: &types.ContainerImage{
|
||||
Name: "test-image",
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user