Exemplo n.º 1
0
func (s *yovpnServer) createEndpoint(c *echo.Context) error {
	region := c.Query("region")
	if len(region) == 0 {
		return echo.NewHTTPError(http.StatusBadRequest, "You need to provide a region!")
	}

	endpoint := s.provisioner.CreateEndpoint(region)
	c.Response().Header().Set(echo.Location, c.Echo().URI(s.getEndpoint, endpoint.ID))
	c.JSON(http.StatusAccepted, endpoint)
	return nil
}
Exemplo n.º 2
0
// Modify 编辑规则
func (self RuleController) Modify(ctx echo.Context) error {
	var data = make(map[string]interface{})

	if ctx.FormValue("submit") == "1" {
		user := ctx.Get("user").(*model.Me)

		errMsg, err := logic.DefaultRule.Save(ctx, ctx.FormParams(), user.Username)
		if err != nil {
			return fail(ctx, 1, errMsg)
		}
		return success(ctx, nil)
	}

	rule := logic.DefaultRule.FindById(ctx, ctx.QueryParam("id"))
	if rule == nil {
		return ctx.Redirect(http.StatusSeeOther, ctx.Echo().URI(echo.HandlerFunc(self.RuleList)))
	}

	data["rule"] = rule

	return render(ctx, "rule/modify.html", data)
}
Exemplo n.º 3
0
// Modify
func (self ArticleController) Modify(ctx echo.Context) error {
	var data = make(map[string]interface{})

	if ctx.FormValue("submit") == "1" {
		user := ctx.Get("user").(*model.Me)
		errMsg, err := logic.DefaultArticle.Modify(ctx, user, ctx.FormParams())
		if err != nil {
			return fail(ctx, 1, errMsg)
		}
		return success(ctx, nil)
	}
	article, err := logic.DefaultArticle.FindById(ctx, ctx.QueryParam("id"))
	if err != nil {
		return ctx.Redirect(http.StatusSeeOther, ctx.Echo().URI(echo.HandlerFunc(self.ArticleList)))
	}

	data["article"] = article
	data["statusSlice"] = model.ArticleStatusSlice
	data["langSlice"] = model.LangSlice

	return render(ctx, "article/modify.html", data)

}
Exemplo n.º 4
0
Arquivo: api.go Projeto: nubunto/vise
func uriBuilder(c echo.Context) func(string) string {
	return func(token string) string {
		return c.Echo().URI(DownloadFile, token)
	}
}