- windsurf_gateway_service: 添加上游延迟/TTFT/错误上下文记录 - endpoint: DeriveUpstreamEndpoint 添加 PlatformWindsurf 分支 - ops_error_logger: guessPlatformFromPath 添加 /windsurf/ 识别
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package routes
|
|
|
|
import (
|
|
"github.com/Wei-Shaw/sub2api/internal/config"
|
|
"github.com/Wei-Shaw/sub2api/internal/handler"
|
|
"github.com/Wei-Shaw/sub2api/internal/server/middleware"
|
|
"github.com/Wei-Shaw/sub2api/internal/service"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func RegisterWindsurfGatewayRoutes(
|
|
r *gin.Engine,
|
|
h *handler.Handlers,
|
|
apiKeyAuth middleware.APIKeyAuthMiddleware,
|
|
apiKeyService *service.APIKeyService,
|
|
subscriptionService *service.SubscriptionService,
|
|
opsService *service.OpsService,
|
|
settingService *service.SettingService,
|
|
cfg *config.Config,
|
|
) {
|
|
if h.Gateway == nil {
|
|
return
|
|
}
|
|
|
|
bodyLimit := middleware.RequestBodyLimit(cfg.Gateway.MaxBodySize)
|
|
clientRequestID := middleware.ClientRequestID()
|
|
opsErrorLogger := handler.OpsErrorLoggerMiddleware(opsService)
|
|
endpointNorm := handler.InboundEndpointMiddleware()
|
|
requireGroupAnthropic := middleware.RequireGroupAssignment(settingService, middleware.AnthropicErrorWriter)
|
|
|
|
windsurfV1 := r.Group("/windsurf/v1")
|
|
windsurfV1.Use(bodyLimit)
|
|
windsurfV1.Use(clientRequestID)
|
|
windsurfV1.Use(opsErrorLogger)
|
|
windsurfV1.Use(endpointNorm)
|
|
windsurfV1.Use(middleware.ForcePlatform(service.PlatformWindsurf))
|
|
windsurfV1.Use(gin.HandlerFunc(apiKeyAuth))
|
|
windsurfV1.Use(requireGroupAnthropic)
|
|
{
|
|
windsurfV1.POST("/messages", h.Gateway.Messages)
|
|
windsurfV1.POST("/chat/completions", h.Gateway.ChatCompletions)
|
|
windsurfV1.GET("/models", h.Gateway.Models)
|
|
}
|
|
}
|