开源软件名称:tango
开源软件地址:https://gitee.com/lunny/tango
开源软件介绍:
Tango 是一个微内核的Go语言Web框架,采用模块化和注入式的设计理念。开发者可根据自身业务逻辑来选择性的装卸框架的功能,甚至利用丰富的中间件来搭建一个全栈式Web开发框架。 特性- 强大而灵活的路由设计
- 兼容已有的
http.Handler - 基于中间件的模块化设计,灵活定制框架功能
- 高性能的依赖注入方式
安装Tango:go get gitea.com/lunny/tango 快速入门一个经典的Tango例子如下: package mainimport ( "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返回 如果将上述例子中的 true 改为 false , 将会得到一个json返回 {"err":"something error"} 这段代码因为拥有一个内嵌的tango.JSON ,所以返回值会被自动的转成Json 文档交流讨论使用案例中间件列表中间件可以重用代码并且简化工作: - 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
LicenseThis project is under BSD License. See the LICENSE file for the full license text. |
请发表评论