Merge branch 'master' of github.com:iron-io/functions into runner-route-not-found

This commit is contained in:
Pedro Nasser
2016-08-30 22:41:09 -03:00
15 changed files with 95 additions and 63 deletions

View File

@@ -106,7 +106,9 @@ func handleRunner(c *gin.Context) {
log.WithField("routes", routes).Debug("Got routes from datastore")
for _, el := range routes {
if params, match := matchRoute(el.Path, route); match {
var stdout, stderr bytes.Buffer
var stdout bytes.Buffer // TODO: should limit the size of this, error if gets too big. akin to: https://golang.org/pkg/io/#LimitReader
stderr := runner.NewFuncLogger(appName, route, el.Image, reqID)
envVars := map[string]string{
"METHOD": c.Request.Method,
@@ -130,13 +132,18 @@ func handleRunner(c *gin.Context) {
envVars["PARAM_"+strings.ToUpper(param.Key)] = param.Value
}
// headers
for header, value := range c.Request.Header {
envVars["HEADER_"+strings.ToUpper(header)] = strings.Join(value, " ")
}
cfg := &runner.Config{
Image: el.Image,
Timeout: 30 * time.Second,
ID: reqID,
AppName: appName,
Stdout: &stdout,
Stderr: &stderr,
Stderr: stderr,
Env: envVars,
}
@@ -151,7 +158,7 @@ func handleRunner(c *gin.Context) {
if result.Status() == "success" {
c.Data(http.StatusOK, "", stdout.Bytes())
} else {
log.WithFields(logrus.Fields{"app": appName, "route": el, "req_id": reqID}).Debug(stderr.String())
// log.WithFields(logrus.Fields{"app": appName, "route": el, "req_id": reqID}).Debug(stderr.String())
c.AbortWithStatus(http.StatusInternalServerError)
}
}