Lunny Xiao
e9a59ae9ec
Some checks reported errors
continuous-integration/drone/push Build was killed
9.0 KiB
9.0 KiB
Tango English
Tango 是一个微内核的Go语言Web框架,采用模块化和注入式的设计理念。开发者可根据自身业务逻辑来选择性的装卸框架的功能,甚至利用丰富的中间件来搭建一个全栈式Web开发框架。
特性
- 强大而灵活的路由设计
- 兼容已有的
http.Handler
- 基于中间件的模块化设计,灵活定制框架功能
- 高性能的依赖注入方式
安装Tango:
go get gitea.com/lunny/tango
快速入门
一个经典的Tango例子如下:
package main
import (
"errors"
"gitea.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 gitea.com/tango/manual-en-US
- 操作手册,您也可以访问 gitea.com/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
License
This project is under BSD License. See the LICENSE file for the full license text.