Files
fn-serverless/api/server/apps_list.go
Pedro Nasser c14bc323f9 added ctx to datastore and improve mock (#329)
Added ctx to datastore and improved mock
2016-11-22 03:33:44 -02:00

27 lines
580 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 handleAppList(c *gin.Context) {
ctx := c.MustGet("ctx").(context.Context)
log := common.Logger(ctx)
filter := &models.AppFilter{}
apps, err := Api.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})
}