package raxmiddleware import ( "net/http" "github.com/gin-gonic/gin" "github.rackspace.com/gorax/clients/raxNewrelic" ) // CtxNewRelic defines the key to store in the gin.Context const CtxNewRelic = "nr" // RaxNewRelic : Initiates NewRelic client and embeds it into the gin context func RaxNewRelic(username, password string) gin.HandlerFunc { return func(c *gin.Context) { nr, err := raxNewrelic.NewClient(username, password) if err != nil { AddError(c, http.StatusInternalServerError, err.Error()) return } c.Set(CtxNewRelic, nr) c.Next() } }