MCPcopy
hub / github.com/iron-io/functions / handleSpecial

Method handleSpecial

api/server/runner.go:31–61  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

29}
30
31func (s *Server) handleSpecial(c *gin.Context) {
32 ctx := c.MustGet("ctx").(context.Context)
33 log := common.Logger(ctx)
34
35 ctx = context.WithValue(ctx, api.AppName, "")
36 c.Set(api.AppName, "")
37 ctx = context.WithValue(ctx, api.Path, c.Request.URL.Path)
38 c.Set(api.Path, c.Request.URL.Path)
39
40 ctx, err := s.UseSpecialHandlers(ctx, c.Request, c.Writer)
41 if err == ErrNoSpecialHandlerFound {
42 log.WithError(err).Errorln("Not special handler found")
43 c.JSON(http.StatusNotFound, http.StatusText(http.StatusNotFound))
44 return
45 } else if err != nil {
46 log.WithError(err).Errorln("Error using special handler!")
47 c.JSON(http.StatusInternalServerError, simpleError(errors.New("Failed to run function")))
48 return
49 }
50
51 c.Set("ctx", ctx)
52 c.Set(api.AppName, ctx.Value(api.AppName).(string))
53 if c.MustGet(api.AppName).(string) == "" {
54 log.WithError(err).Errorln("Specialhandler returned empty app name")
55 c.JSON(http.StatusBadRequest, simpleError(models.ErrRunnerRouteNotFound))
56 return
57 }
58
59 // now call the normal runner call
60 s.handleRequest(c, nil)
61}
62
63func toEnvName(envtype, name string) string {
64 name = strings.ToUpper(strings.Replace(name, "-", "_", -1))

Callers

nothing calls this directly

Calls 5

UseSpecialHandlersMethod · 0.95
handleRequestMethod · 0.95
simpleErrorFunction · 0.85
LoggerMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected