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

Method AppHandleStreamHTTP

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

Source from the content-addressed store, hash-verified

87}
88
89func (i *imlMcpController) AppHandleStreamHTTP(ctx *gin.Context) {
90 apikey := ctx.Request.Header.Get("Authorization")
91 apikey = strings.TrimPrefix(apikey, "Bearer ")
92 if apikey == "" {
93 ctx.AbortWithStatusJSON(403, gin.H{"code": -1, "msg": "invalid apikey", "success": "fail"})
94 return
95 }
96 appId := ctx.Request.Header.Get("X-Application-Id")
97 if appId == "" {
98 ctx.AbortWithStatusJSON(403, gin.H{"code": -1, "msg": "invalid app id", "success": "fail"})
99 return
100 }
101 cfg := i.settingModule.Get(ctx)
102 req := ctx.Request.WithContext(utils.SetGatewayInvoke(ctx.Request.Context(), cfg.InvokeAddress))
103
104 req = req.WithContext(utils.SetLabel(req.Context(), "apikey", apikey))
105 req = req.WithContext(utils.SetLabel(req.Context(), "app", appId))
106 req.URL.Path = mcp_server.OpenGlobalMCPPath
107 i.openStreamableServer.ServeHTTP(ctx.Writer, req)
108}
109
110func (i *imlMcpController) AppMCPConfig(ctx *gin.Context, appId string) (string, error) {
111 cfg := i.settingModule.Get(ctx)

Callers

nothing calls this directly

Calls 2

GetMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected