refactor(api): unify routes under /api/v1/d, agent, relay, tunnel

Remove the /openflare prefix from management APIs (/api/v1/d/*) and move
Agent, Relay, and Tunnel protocol endpoints under /api/v1. Update Wavelet
frontend services and node client binaries to match.
This commit is contained in:
ryan
2026-06-19 11:08:06 +08:00
parent 6bd7dc91fc
commit 71ebfa555f
48 changed files with 18463 additions and 21924 deletions
-5
View File
@@ -18,7 +18,6 @@ import (
"github.com/Rain-kl/Wavelet/internal/apps/risk_control"
router_root "github.com/Rain-kl/Wavelet/internal/router/root"
v1 "github.com/Rain-kl/Wavelet/internal/router/v1"
ofrouter "github.com/Rain-kl/Wavelet/internal/router/v1/openflare"
"github.com/Rain-kl/Wavelet/internal/apps/oauth"
"github.com/Rain-kl/Wavelet/internal/config"
@@ -116,10 +115,6 @@ func registerRoutes(r *gin.Engine) {
apiGroup := r.Group(config.Config.App.APIPrefix)
{
// OpenFlare Agent/Relay/Flared protocol routes under /api/*
ofrouter.RegisterRoutes(apiGroup)
// API V1
apiV1Router := apiGroup.Group("/v1")
{
v1.RegisterV1Routes(apiV1Router, apiGroup)
@@ -2,15 +2,15 @@
// SPDX-License-Identifier: Apache-2.0
// Package openflare registers OpenFlare HTTP routes.
// Management console APIs are mounted via RegisterV1Routes under /api/v1/openflare.
// Agent/Relay/Flared protocol routes are mounted via RegisterRoutes under /api.
// Management console APIs are mounted via RegisterV1Routes under /api/v1/d.
// Agent/Relay/Tunnel protocol routes are mounted via RegisterRoutes under /api/v1.
package openflare
import "github.com/gin-gonic/gin"
// RegisterRoutes mounts Agent/Relay/Flared protocol routes under the /api group.
func RegisterRoutes(apiGroup *gin.RouterGroup) {
registerAgentRoutes(apiGroup)
registerRelayRoutes(apiGroup)
registerFlaredRoutes(apiGroup)
// RegisterRoutes mounts Agent/Relay/Tunnel protocol routes under the /api/v1 group.
func RegisterRoutes(apiV1Router *gin.RouterGroup) {
registerAgentRoutes(apiV1Router)
registerRelayRoutes(apiV1Router)
registerTunnelRoutes(apiV1Router)
}
@@ -8,8 +8,8 @@ import (
"github.com/gin-gonic/gin"
)
func registerAgentRoutes(apiGroup *gin.RouterGroup) {
agentRoute := apiGroup.Group("/agent")
func registerAgentRoutes(apiV1Router *gin.RouterGroup) {
agentRoute := apiV1Router.Group("/agent")
{
discoveryRoute := agentRoute.Group("/")
discoveryRoute.Use(agent.AgentRegisterAuth())
@@ -9,8 +9,8 @@ import (
"github.com/gin-gonic/gin"
)
func registerRelayRoutes(apiGroup *gin.RouterGroup) {
relayRoute := apiGroup.Group("/relay")
func registerRelayRoutes(apiV1Router *gin.RouterGroup) {
relayRoute := apiV1Router.Group("/relay")
relayRoute.Use(relay.RelayAuth())
{
relayRoute.POST("/heartbeat", relay.PostHeartbeat)
@@ -18,13 +18,13 @@ func registerRelayRoutes(apiGroup *gin.RouterGroup) {
}
}
func registerFlaredRoutes(apiGroup *gin.RouterGroup) {
flaredRoute := apiGroup.Group("/flared")
flaredRoute.Use(flared.TunnelAuth())
func registerTunnelRoutes(apiV1Router *gin.RouterGroup) {
tunnelRoute := apiV1Router.Group("/tunnel")
tunnelRoute.Use(flared.TunnelAuth())
{
flaredRoute.POST("/heartbeat", flared.PostHeartbeat)
flaredRoute.GET("/config/active", flared.GetActiveConfig)
flaredRoute.POST("/apply-log", flared.PostApplyLog)
flaredRoute.GET("/ws", flared.GetWebSocket)
tunnelRoute.POST("/heartbeat", flared.PostHeartbeat)
tunnelRoute.GET("/config/active", flared.GetActiveConfig)
tunnelRoute.POST("/apply-log", flared.PostApplyLog)
tunnelRoute.GET("/ws", flared.GetWebSocket)
}
}
+3 -3
View File
@@ -6,11 +6,11 @@ package openflare
import "github.com/gin-gonic/gin"
// V1BasePath is the OpenFlare console API prefix under /api/v1.
const V1BasePath = "/api/v1/openflare"
const V1BasePath = "/api/v1/d"
// RegisterV1Routes mounts OpenFlare management console APIs under /api/v1/openflare.
// RegisterV1Routes mounts OpenFlare management console APIs under /api/v1/d.
func RegisterV1Routes(apiV1Router *gin.RouterGroup) {
group := apiV1Router.Group("/openflare")
group := apiV1Router.Group("/d")
registerOptionRoutes(group)
registerOriginRoutes(group)
registerApplyLogRoutes(group)
+2 -1
View File
@@ -17,8 +17,9 @@ func RegisterV1Routes(apiV1Router *gin.RouterGroup, apiGroup *gin.RouterGroup) {
// 2. Admin routes
RegisterAdminRoutes(apiV1Router)
// 3. OpenFlare management console APIs
// 3. OpenFlare management console APIs and Agent/Relay/Tunnel protocol routes
ofrouter.RegisterV1Routes(apiV1Router)
ofrouter.RegisterRoutes(apiV1Router)
// 4. Custom business routes (example only)
RegisterCustomRoutes(apiV1Router)