Revel - 基于Go语言的高生产率Web开发框架
jopen
12年前
这是一个基于Go语言的高生产率Web开发框架,它以 Play! Framework为蓝本。
功能特性
热编译(Hot Compile)
Edit, save, and refresh. Revel compiles your code and templates for you, so you don't miss a beat. Code doesn't compile? It gives you a helpful description. Run-time code panic? Revel has you covered.
Simplicity Optional
Revel tries to provide a comprehensive toolkit for making everyday web apps.
Don't want to use some of the helpers? Revel gets out of the way and gives you direct access to the underlying request and response.
Blocking
Revel builds on top of the Go HTTP server, which runs each request in its own goroutine. Write simple blocking code without guilt.
以下是一个示例:
// app/controllers/app.go 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) }