Files
fn-serverless/api/server/apps_list.go
Pedro Nasser 49a7712e6b API improvements (#410)
* api improvements, remove global Api object and reduce gin dependency

* requested changes
2016-12-09 15:24:35 -02:00

27 lines
590 B
Go

package server
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/iron-io/functions/api/models"
"github.com/iron-io/runner/common"
)
func (s *Server) handleAppList(c *gin.Context) {
ctx := c.MustGet("ctx").(context.Context)
log := common.Logger(ctx)
filter := &models.AppFilter{}
apps, err := s.Datastore.GetApps(ctx, filter)
if err != nil {
log.WithError(err).Debug(models.ErrAppsList)
c.JSON(http.StatusInternalServerError, simpleError(models.ErrAppsList))
return
}
c.JSON(http.StatusOK, appsResponse{"Successfully listed applications", apps})
}