Beispiel #1
0
func PublishApplication(c *echo.Context) error {
	app := &apps.Application{}
	err := utils.ParseJSONBody(c, app)
	if err != nil {
		return err
	}

	user := c.Get("user").(*users.User)

	err = apps.PublishApp(user, app)
	if err != nil {
		return err
	}

	return utils.JSON(c, http.StatusOK, app)
}
Beispiel #2
0
func PublishApplication(c *echo.Context) error {
	var params struct {
		Data struct {
			Attributes struct {
				Path string `json:"path"`
			}
		}
	}

	err := utils.ParseJSONBody(c, &params)
	if err != nil {
		return nil
	}

	trimmedpath := strings.TrimSpace(params.Data.Attributes.Path)
	if trimmedpath == "" {
		return c.JSON(http.StatusBadRequest, hash{
			"error": [1]hash{
				hash{
					"detail": "App path is empty",
				},
			},
		})
	}
	err = apps.PublishApp(trimmedpath)
	if err == apps.PublishFailed {
		return c.JSON(http.StatusInternalServerError, hash{
			"error": [1]hash{
				hash{
					"detail": err,
				},
			},
		})
	}

	return c.JSON(http.StatusOK, hash{
		"data": hash{
			"success": true,
		},
	})
}