diff --git a/docs/changelog/index.md b/docs/changelog/index.md index 4563dae9..02647859 100644 --- a/docs/changelog/index.md +++ b/docs/changelog/index.md @@ -26,6 +26,8 @@ sidebar: false - 前端页面鉴权改为默认私域:除 `/login`、`/register`、`/callback` 外,未登录访问任意页面(含数据看板 `/`)均重定向至登录页。 +- 重构优化:收敛 `flared` 和 `relay` 客户端模块中重复声明的 `APIResponse` 结构体,统一通过类型别名复用 `pkg/protocol.APIResponse`。 + ### 修复 - 修复 Agent 升级版本比对逻辑:使用统一的 `pkg/utils.CompareVersions` 对比版本,正确处理预览/预发布版本(如 `v3.0.0-beta` 升级到 `v3.0.0-beta.1`),避免升级按钮非预期禁用的问题。 diff --git a/internal/apps/custom/routers.go b/internal/apps/custom/routers.go deleted file mode 100644 index cb377fbe..00000000 --- a/internal/apps/custom/routers.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2026 Arctel.net -// SPDX-License-Identifier: Apache-2.0 - -// Package custom provides custom business handlers -package custom - -import ( - "net/http" - - "github.com/gin-gonic/gin" - - "github.com/Rain-kl/Wavelet/internal/common/response" -) - -// Hello is a sample handler for custom business logic -// @Summary Sample Hello API -// @Description A sample business API for customization -// @Tags custom -// @Produce json -// @Success 200 {object} response.Any{data=string} "成功" -// @Router /api/v1/custom/hello [get] -func Hello(c *gin.Context) { - c.JSON(http.StatusOK, response.OK("Hello from custom business module!")) -} diff --git a/internal/apps/flared/httpclient/client.go b/internal/apps/flared/httpclient/client.go index 9dd284a2..2426f21e 100644 --- a/internal/apps/flared/httpclient/client.go +++ b/internal/apps/flared/httpclient/client.go @@ -9,11 +9,8 @@ import ( service "github.com/Rain-kl/Wavelet/pkg/protocol" ) -// APIResponse is the standard JSON envelope returned by the Wavelet API. -type APIResponse[T any] struct { - ErrorMsg string `json:"error_msg"` - Data T `json:"data"` -} +// APIResponse is an alias for service.APIResponse. +type APIResponse[T any] = service.APIResponse[T] // Client is the HTTP client for the flared tunnel API. type Client struct { diff --git a/internal/apps/relay/httpclient/client.go b/internal/apps/relay/httpclient/client.go index 0d584be0..8176cc55 100644 --- a/internal/apps/relay/httpclient/client.go +++ b/internal/apps/relay/httpclient/client.go @@ -9,11 +9,8 @@ import ( service "github.com/Rain-kl/Wavelet/pkg/protocol" ) -// APIResponse wraps a control-plane API response with an optional error message. -type APIResponse[T any] struct { - ErrorMsg string `json:"error_msg"` - Data T `json:"data"` -} +// APIResponse is an alias for service.APIResponse. +type APIResponse[T any] = service.APIResponse[T] // Client sends authenticated requests to the relay control-plane API. type Client struct { diff --git a/internal/router/v1/custom.go b/internal/router/v1/custom.go index ba88641d..15b1942b 100644 --- a/internal/router/v1/custom.go +++ b/internal/router/v1/custom.go @@ -4,15 +4,7 @@ // Package v1 contains router registrations for API V1 package v1 -import ( - "github.com/Rain-kl/Wavelet/internal/apps/custom" - "github.com/gin-gonic/gin" -) - // RegisterCustomRoutes registers custom business routes to keep routing clean and stable. -func RegisterCustomRoutes(apiV1Router *gin.RouterGroup) { - customRouter := apiV1Router.Group("/custom") - { - customRouter.GET("/hello", custom.Hello) - } +func RegisterCustomRoutes() { + } diff --git a/internal/router/v1/v1.go b/internal/router/v1/v1.go index 8efd4183..33b0b51a 100644 --- a/internal/router/v1/v1.go +++ b/internal/router/v1/v1.go @@ -22,5 +22,5 @@ func RegisterV1Routes(apiV1Router *gin.RouterGroup, apiGroup *gin.RouterGroup) { ofrouter.RegisterRoutes(apiV1Router) // 4. Custom business routes (example only) - RegisterCustomRoutes(apiV1Router) + RegisterCustomRoutes() }