| 32 | } |
| 33 | |
| 34 | func (i *imlMcpController) AppMCPHandle(ctx *gin.Context) { |
| 35 | appId := ctx.Param("app") |
| 36 | if appId == "" { |
| 37 | ctx.AbortWithStatusJSON(403, gin.H{"code": -1, "msg": "invalid app id", "success": "fail"}) |
| 38 | return |
| 39 | } |
| 40 | cfg := i.settingModule.Get(ctx) |
| 41 | req := ctx.Request.WithContext(utils.SetGatewayInvoke(ctx.Request.Context(), cfg.InvokeAddress)) |
| 42 | req = req.WithContext(utils.SetLabel(req.Context(), "app", appId)) |
| 43 | paths := strings.Split(req.URL.Path, "/") |
| 44 | req.URL.Path = fmt.Sprintf("/api/v1/%s/%s", mcp_server.GlobalBasePath, paths[len(paths)-1]) |
| 45 | locale := utils.I18n(ctx) |
| 46 | if v, ok := i.sseServers[locale]; ok { |
| 47 | v.ServeHTTP(ctx.Writer, req) |
| 48 | return |
| 49 | } |
| 50 | |
| 51 | i.sseServers[languageEnUs].ServeHTTP(ctx.Writer, req) |
| 52 | } |
| 53 | |
| 54 | func (i *imlMcpController) AppHandleSSE(ctx *gin.Context) { |
| 55 | apikey := ctx.Request.URL.Query().Get("apikey") |