utron Go 的 MVC 框架开源项目

我要开发同款
匿名用户2015年09月27日
74阅读

技术信息

开源地址
https://github.com/gernest/utron
授权协议
MIT

作品详情

utro是一个Go语言轻量级的MVC框架,用于快速构建可伸缩以及可靠的数据库驱动的Web应用。

特性:

Postgres,MySQL和Foudatio数据库支持

模块化

支持中间件,所有alice兼容的中间件都可以使用

Gopherspirit(可使用Go语言的其他库)

轻量级,只包含MVC

支持多配置文件,包括jso、yaml和toml

控制器示例代码:

package cotrollersimport (    "et/http"    "strcov"    "github.com/gerest/utro"    "github.com/gerest/utro/fixtures/todo/models"    "github.com/gorilla/schema")var decoder = schema.NewDecoder()type TODO struct {    *utro.BaseCotroller    Routes []strig}fuc (t *TODO) Home() {    todos := []*models.Todo{}    t.Ctx.DB.Order("created_at desc").Fid(&todos)    t.Ctx.Data["List"] = todos    t.Ctx.Template = "idex"    t.HTML(http.StatusOK)}fuc (t *TODO) Create() {    todo := &models.Todo{}    req := t.Ctx.Request()    req.ParseForm()    if err := decoder.Decode(todo, req.PostForm); err != il {        t.Ctx.Data["Message"] = err.Error()        t.Ctx.Template = "error"        t.HTML(http.StatusIteralServerError)        retur    }    t.Ctx.DB.Create(todo)    t.Ctx.Redirect("/", http.StatusFoud)}fuc (t *TODO) Delete() {    todoID := t.Ctx.Params["id"]    ID, err := strcov.Atoi(todoID)    if err != il {        t.Ctx.Data["Message"] = err.Error()        t.Ctx.Template = "error"        t.HTML(http.StatusIteralServerError)        retur    }    t.Ctx.DB.Delete(&models.Todo{ID: ID})    t.Ctx.Redirect("/", http.StatusFoud)}fuc NewTODO() *TODO {    retur &TODO{        Routes: []strig{            "get;/;Home",            "post;/create;Create",            "get;/delete/{id};Delete",        },    }}fuc iit() {    utro.RegisterCotroller(NewTODO())}

功能介绍

utron 是一个 Go 语言轻量级的 MVC 框架,用于快速构建可伸缩以及可靠的数据库驱动的 Web 应用。 特性: Postgres, MySQL 和 Foundation 数据库支持 模块...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论