Revel v0.11.2 ダウンロード、フルスタックのWebフレームワーク

ダウンロード
提供元サイトからダウンロード

アップグレード
$ go get -u github.com/revel/cmd/revel
$ revel build github.com/myusername/myproject /path/to/destination/folder

サンプルコード:

type Application struct {
*rev.Controller
}

func (c Application) Register() rev.Result {
title := “Register"
return c.Render(title)
}

func (c Application) SaveUser(user models.User, verifyPassword string) rev.Result {
c.Validation.Required(verifyPassword).Key(“verifyPassword")
c.Validation.Required(verifyPassword == user.Password).Key(“verifyPassword").
Message(“Password does not match")
user.Validate(c.Validation)

if c.Validation.HasErrors() {
c.Validation.Keep()
c.FlashParams()
return c.Redirect(Application.Register)
}

_, err := c.Txn.Exec(“insert into User (Username, Password, Name) values (?, ?, ?)",
user.Username, user.Password, user.Name)
if err != nil {
panic(err)
}

c.Session[“user"] = user.Username
c.Flash.Success(“Welcome, " + user.Name)
return c.Redirect(Hotels.Index)
}

OpenSource

Posted by arkgame