mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
32 lines
808 B
Go
32 lines
808 B
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/iron-io/functions/api"
|
|
"github.com/iron-io/functions/api/models"
|
|
"github.com/iron-io/runner/common"
|
|
)
|
|
|
|
func (s *Server) handleAppGet(c *gin.Context) {
|
|
ctx := c.MustGet("ctx").(context.Context)
|
|
log := common.Logger(ctx)
|
|
|
|
appName := c.MustGet(api.AppName).(string)
|
|
app, err := s.Datastore.GetApp(ctx, appName)
|
|
|
|
if err != nil && err != models.ErrAppsNotFound {
|
|
log.WithError(err).Error(models.ErrAppsGet)
|
|
c.JSON(http.StatusInternalServerError, simpleError(models.ErrAppsGet))
|
|
return
|
|
} else if app == nil {
|
|
log.WithError(err).Error(models.ErrAppsNotFound)
|
|
c.JSON(http.StatusNotFound, simpleError(models.ErrAppsNotFound))
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, appResponse{"Successfully loaded app", app})
|
|
}
|