mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
34 lines
739 B
Go
34 lines
739 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/iron-io/functions/api/models"
|
|
titancommon "github.com/iron-io/worker/common"
|
|
)
|
|
|
|
func handleAppGet(c *gin.Context) {
|
|
ctx := c.MustGet("ctx").(context.Context)
|
|
log := titancommon.Logger(ctx)
|
|
|
|
appName := c.Param("app")
|
|
app, err := Api.Datastore.GetApp(appName)
|
|
|
|
if err != nil {
|
|
log.WithError(err).Error(models.ErrAppsGet)
|
|
c.JSON(http.StatusInternalServerError, simpleError(models.ErrAppsGet))
|
|
return
|
|
}
|
|
|
|
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})
|
|
}
|