MCPcopy Create free account
hub / github.com/bricks-cloud/BricksLLM / CorsMiddleware

Function CorsMiddleware

internal/server/web/proxy/proxy.go:63–80  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

61}
62
63func CorsMiddleware() gin.HandlerFunc {
64 return func(c *gin.Context) {
65 a_or_b := func(a, b string) string {
66 if a != "" {
67 return a
68 } else {
69 return b
70 }
71 }
72 c.Header("Access-Control-Allow-Origin", a_or_b(c.GetHeader("Origin"), "*"))
73 if c.Request.Method == "OPTIONS" {
74 c.Header("Access-Control-Allow-Methods", a_or_b(c.GetHeader("Access-Control-Request-Method"), "*"))
75 c.Header("Access-Control-Allow-Headers", a_or_b(c.GetHeader("Access-Control-Request-Headers"), "*"))
76 c.Header("Access-Control-Max-Age", "3600")
77 c.AbortWithStatus(204)
78 }
79 }
80}
81
82func NewProxyServer(log *zap.Logger, mode, privacyMode string, c cache, m KeyManager, rm routeManager, a authenticator, psm ProviderSettingsManager, cpm CustomProvidersManager, ks keyStorage, e estimator, ae anthropicEstimator, aoe azureEstimator, v validator, r recorder, pub publisher, rlm rateLimitManager, timeout time.Duration, ac accessCache, uac userAccessCache, pm PoliciesManager, scanner Scanner, cd CustomPolicyDetector, die deepinfraEstimator, um userManager, removeAgentHeaders bool) (*ProxyServer, error) {
83 router := gin.New()

Callers 1

NewProxyServerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected