Tango
English
Tango 是一个微内核的Go语言Web框架,采用模块化和注入式的设计理念。开发者可根据自身业务逻辑来选择性的装卸框架的功能,甚至利用丰富的中间件来搭建一个全栈式Web开发框架。
- [2016-5-12] 开放Route级别中间件支持
- [2016-3-16] Group完善中间件支持,Route支持中间件
- [2016-2-1] 新增 session-ssdb,支持将ssdb作为session的后端存储
- [2015-10-23] 更新renders插件,解决模板修改后需要刷新两次才能生效的问题
- 强大而灵活的路由设计
- 兼容已有的
http.Handler
- 基于中间件的模块化设计,灵活定制框架功能
- 高性能的依赖注入方式
go get github.com/lunny/tango
一个经典的Tango例子如下:
package main
import (
"errors"
"github.com/lunny/tango"
)
type Action struct {
tango.JSON
}
func (Action) Get() interface{} {
if true {
return map[string]string{
"say": "Hello tango!",
}
}
return errors.New("something error")
}
func main() {
t := tango.Classic()
t.Get("/", new(Action))
t.Run()
}
然后在浏览器访问http://localhost:8000
, 将会得到一个json返回
{"say":"Hello tango!"}
如果将上述例子中的 true
改为 false
, 将会得到一个json返回
{"err":"something error"}
这段代码因为拥有一个内嵌的tango.JSON
,所以返回值会被自动的转成Json
- Manual, And you are welcome to contribue for the book by git PR to github.com/go-tango/manual-en-US
- 操作手册,您也可以访问 github.com/go-tango/manual-zh-CN为本手册进行贡献
- API Reference
- QQ群:369240307
- 论坛
- 会计人论坛 - 会计人论坛
- GopherTC - Golang China
- Wego tango结合xorm开发的论坛
- Pugo 博客
- DBWeb 基于Web的数据库管理工具
- Godaily - github RSS聚合工具
- Gos 简易的Web静态文件服务端
- GoFtpd - 纯Go的跨平台FTP服务器
中间件可以重用代码并且简化工作:
- recovery - recover after panic
- compress - Gzip & Deflate compression
- static - Serves static files
- logger - Log the request & inject Logger to action struct
- param - get the router parameters
- return - Handle the returned value smartlly
- context - Inject context to action struct
- session -
Session manager, session-redis, session-nodb, session-ledis, session-ssdb
- xsrf -
Generates and validates csrf tokens
- binding -
Bind and validates forms
- renders -
Go template engine
- dispatch -
Multiple Application support on one server
- tpongo2 -
Pongo2 teamplte engine support
- captcha -
Captcha
- events -
Before and After
- flash -
Share data between requests
- debug -
show detail debug infomaton on log
- basicauth -
basicauth middleware
- authz -
manage permissions via ACL, RBAC, ABAC
- cache -
cache middleware - cache-memory, cache-file, cache-ledis, cache-nodb, cache-mysql, cache-postgres, cache-memcache, cache-redis
- rbac -
rbac control
This project is under BSD License. See the LICENSE file for the full license text.