分享
ThinkGo:一个轻量级的 Go 语言 MVC 框架
TechLee · · 1116 次点击 · · 开始浏览这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。
ThinkGo 是一个轻量级的 Go 语言 MVC 框架,目前支持路由、中间件、控制器、请求、响应、Session、视图、日志、缓存、ORM等 web 框架应该具备的基本功能,ThinkGo致力于让代码简洁且富于表达力,帮助开发者快速构建一个 Web 应用。
特性
- 简洁的路由,支持参数注入
- 强大的路由中间件,支持
前置/后置中间件 - Session支持,支持cookie、redis及自定义存储
- 强大的日志服务,支持多通道存储,遵循
RFC 5424规范。 - 缓存,支持memory、redis及自定义缓存驱动
- 简洁的ORM,能使用原生 SQL、流畅的查询构造器
安装
go get github.com/thinkoner/thinkgo
快速开始
package main
import (
"github.com/thinkoner/thinkgo"
"fmt"
"github.com/thinkoner/thinkgo/router"
"github.com/thinkoner/thinkgo/context"
)
func main() {
app := thinkgo.BootStrap()
app.RegisterRoute(func(route *router.Route) {
route.Get("/", func(req *context.Request) *context.Response {
return thinkgo.Text("Hello ThinkGo !")
})
route.Get("/ping", func(req *context.Request) *context.Response {
return thinkgo.Json(map[string]string{
"message": "pong",
})
})
// Dependency injection
route.Get("/user/{name}", func(req *context.Request, name string) *context.Response {
return thinkgo.Text(fmt.Sprintf("Hello %s !", name))
})
})
// listen and serve on 0.0.0.0:9011
app.Run()
}
协议
ThinkGo 采用 Apache 2.0 开源协议发布。
项目地址
- GitHub: https://github.com/thinkoner/...
- Gitee: https://gitee.com/thinkgo/thi...
联系作者
https://github.com/thinkoner/...
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
关注微信1116 次点击
上一篇:有趣的defer
添加一条新回复
(您需要 后才能回复 没有账号 ?)
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传
收入到我管理的专栏 新建专栏
ThinkGo 是一个轻量级的 Go 语言 MVC 框架,目前支持路由、中间件、控制器、请求、响应、Session、视图、日志、缓存、ORM等 web 框架应该具备的基本功能,ThinkGo致力于让代码简洁且富于表达力,帮助开发者快速构建一个 Web 应用。
特性
- 简洁的路由,支持参数注入
- 强大的路由中间件,支持
前置/后置中间件 - Session支持,支持cookie、redis及自定义存储
- 强大的日志服务,支持多通道存储,遵循
RFC 5424规范。 - 缓存,支持memory、redis及自定义缓存驱动
- 简洁的ORM,能使用原生 SQL、流畅的查询构造器
安装
go get github.com/thinkoner/thinkgo
快速开始
package main
import (
"github.com/thinkoner/thinkgo"
"fmt"
"github.com/thinkoner/thinkgo/router"
"github.com/thinkoner/thinkgo/context"
)
func main() {
app := thinkgo.BootStrap()
app.RegisterRoute(func(route *router.Route) {
route.Get("/", func(req *context.Request) *context.Response {
return thinkgo.Text("Hello ThinkGo !")
})
route.Get("/ping", func(req *context.Request) *context.Response {
return thinkgo.Json(map[string]string{
"message": "pong",
})
})
// Dependency injection
route.Get("/user/{name}", func(req *context.Request, name string) *context.Response {
return thinkgo.Text(fmt.Sprintf("Hello %s !", name))
})
})
// listen and serve on 0.0.0.0:9011
app.Run()
}
协议
ThinkGo 采用 Apache 2.0 开源协议发布。
项目地址
- GitHub: https://github.com/thinkoner/...
- Gitee: https://gitee.com/thinkgo/thi...