发布于 2015-03-25 23:53:48 | 184 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

Revel Go 语言 Web 框架

Revel是一个高生产力的 Go 语言 Web 框架 .其思路完全来自 Java 的 Play Framework。


Revel v0.12.0 发布,此版本主要是添加导入路径到所有新的 Revel 测试 testing 子包 :

package tests
import "github.com/revel/revel/testing"
type AppTest struct {
    testing.TestSuite
}

同时还改进了内部组织结构,更多内容请看发行说明

此版本现已提供下载:https://github.com/revel/revel/archive/v0.12.0.zip

Revel是一个高生产力的 Go 语言 Web 框架 .其思路完全来自 Java 的 Play Framework。

控制器示例:

// 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)
}


历史版本 :
Revel v0.17.1 发布,Go 的全堆栈 Web 框架
Revel v0.15.0 发布,Go 的全堆栈 Web 框架
Revel v0.14.0 发布,Go 的全堆栈 Web 框架
Revel v0.12.0 发布,Go 的全堆栈 Web 框架
Revel v0.11.3 发布,Go 的全堆栈 Web 框架
Revel v0.11.2 发布,Go 的全堆栈 Web 框架
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务