(ctx *gin.Context)
| 243 | } |
| 244 | |
| 245 | func (i *imlMcpController) ServiceHandleStreamHTTP(ctx *gin.Context) { |
| 246 | apikey := ctx.Request.Header.Get("Authorization") |
| 247 | serviceId := ctx.Request.Header.Get("X-Service-Id") |
| 248 | if serviceId == "" { |
| 249 | ctx.AbortWithStatusJSON(403, gin.H{"code": -1, "msg": "invalid service id", "success": "fail"}) |
| 250 | return |
| 251 | } |
| 252 | apikey = strings.TrimPrefix(apikey, "Bearer ") |
| 253 | ok, err := i.authorizationModule.CheckAPIKeyAuthorizationByService(ctx, serviceId, apikey) |
| 254 | if err != nil { |
| 255 | ctx.AbortWithStatusJSON(403, gin.H{"code": -1, "msg": err.Error(), "success": "fail"}) |
| 256 | return |
| 257 | } |
| 258 | if !ok { |
| 259 | ctx.AbortWithStatusJSON(403, gin.H{"code": -1, "msg": "invalid apikey", "success": "fail"}) |
| 260 | return |
| 261 | } |
| 262 | cfg := i.settingModule.Get(ctx) |
| 263 | req := ctx.Request.WithContext(utils.SetGatewayInvoke(ctx.Request.Context(), cfg.InvokeAddress)) |
| 264 | req = req.WithContext(utils.SetLabel(req.Context(), "apikey", apikey)) |
| 265 | mcp_server.DefaultMCPServer().ServeHTTP(ctx.Writer, req) |
| 266 | } |
| 267 | |
| 268 | func (i *imlMcpController) handleMessage(ctx *gin.Context, server http.Handler) { |
| 269 | sessionId := ctx.Request.URL.Query().Get("sessionId") |
nothing calls this directly
no test coverage detected