Files
fn-serverless/api/server/apps_get.go
Pedro Nasser a80fe9c897 Fix datastore error for inexistent app (#493)
* fix datastore error inexistent app

* fix get route error handling

* fix API errors handling and tests
2017-01-26 14:41:18 -08:00

23 lines
428 B
Go

package server
import (
"context"
"net/http"
"github.com/gin-gonic/gin"
"github.com/iron-io/functions/api"
)
func (s *Server) handleAppGet(c *gin.Context) {
ctx := c.MustGet("ctx").(context.Context)
appName := c.MustGet(api.AppName).(string)
app, err := s.Datastore.GetApp(ctx, appName)
if err != nil {
handleErrorResponse(c, err)
return
}
c.JSON(http.StatusOK, appResponse{"Successfully loaded app", app})
}