Files
sub2api/backend/internal/handler/gateway_platform.go
shaw f08f9111e5 refactor(platform-seam): gatewayplatform 接缝——Provider/Registry + 两处 Forward 分发替换
经双视角评审裁决的收窄版 Phase-3 接缝(零行为变更):
- internal/gatewayplatform:Provider{Platform,Forward} 两方法 v1 接口 +
  ForwardRequest{Parsed,Body,IsStickySession,SessionGroupID,SessionKey} +
  构造期注册 Registry(重复 panic,运行期并发只读)
- 3 个单语句直返 adapter(anthropic/antigravity/gemini,错误零包裹——
  BetaBlockedError/PromptTooLong 的 errors.As 链由 T4 特征化守护)
- Messages 端点两处平台分发改 registry 查找;Type!=APIKey 条件保留调用点
- OpenAI(独立 handler)、v1beta 端点、内核 internal/plugin 零触碰

门禁:T1-T5 特征化全绿、安全网 45 包、bench allocs 全部持平(266/329/93/134)。
2026-06-12 00:27:10 +08:00

21 lines
793 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package handler
import (
"github.com/Wei-Shaw/sub2api/internal/gatewayplatform"
"github.com/Wei-Shaw/sub2api/internal/service"
)
// ProvideGatewayPlatformRegistry 装配 /v1/messages 平台 Forward 分发注册表
// (Phase-3 SEAM-DESIGN 裁决:anthropic / antigravity / gemini 三 adapter;
// OpenAI 走独立 OpenAIGatewayHandler 与独立计费管线,不进本注册表)。
func ProvideGatewayPlatformRegistry(
gatewayService *service.GatewayService,
antigravityGatewayService *service.AntigravityGatewayService,
) *gatewayplatform.Registry {
return gatewayplatform.NewRegistry(
gatewayplatform.NewAnthropicProvider(gatewayService),
gatewayplatform.NewAntigravityProvider(antigravityGatewayService),
gatewayplatform.NewGeminiProvider(antigravityGatewayService),
)
}