MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / AppMCPHandle

Method AppMCPHandle

controller/mcp/iml.go:34–52  ·  view source on GitHub ↗
(ctx *gin.Context)

Source from the content-addressed store, hash-verified

32}
33
34func (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
54func (i *imlMcpController) AppHandleSSE(ctx *gin.Context) {
55 apikey := ctx.Request.URL.Query().Get("apikey")

Callers

nothing calls this directly

Calls 2

GetMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected