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

Method ServiceHandleStreamHTTP

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

Source from the content-addressed store, hash-verified

243}
244
245func (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
268func (i *imlMcpController) handleMessage(ctx *gin.Context, server http.Handler) {
269 sessionId := ctx.Request.URL.Query().Get("sessionId")

Callers

nothing calls this directly

Calls 3

GetMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected