README_CN.md 5.6 KB

Tango Build Status English

Tango Logo

Tango 是一个微内核易扩展的Go语言Web框架.

当前版本: v0.2.8 版本更新记录

简介

安装Tango:

go get github.com/lunny/tango

最简单的例子:

package main

import "github.com/lunny/tango"

func main() {
    t := tango.Classic()
    t.Get("/", func() string {
        return "Hello tango!"
    })
    t.Run()
}

然后在浏览器访问http://localhost:8000即可。当然了,tango其实对struct形式的支持更好。比如:

package main

import "github.com/lunny/tango"

type Action struct {
    tango.Json
}

func (Action) Get() map[string]string {
    return map[string]string{
        "say": "Hello tango!",
    }
}

func main() {
    t := tango.Classic()
    t.Get("/", new(Action))
    t.Run()
}

这段代码因为拥有一个内嵌的tango.Json,所以返回值会被自动的转成Json。具体返回可以参见以下文档。

源码文档 godocWiki

特性

  • 强大而灵活的路由设计
  • 兼容已有的http.Handler
  • 模块化设计,可以很容易写出自定义插件
  • 高性能的依赖注入方式

中间件

中间件让你像切面编程那样来操作你的Controller。

目前已有很多 中间件,可以帮助你来简化工作:

  • 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
  • request - Inject request to action struct
  • response - Inject response to action struct
  • session - Build Status Session manager
  • xsrf - Build Status Generates and validates csrf tokens
  • binding - Build Status Bind and validates forms
  • renders - Build Status Go template engine
  • dispatch - Build Status Multiple Application support on one server
  • tpongo2 - Build Status Pongo2 teamplte engine support
  • captcha - Build Status Captcha
  • events - Build Status Before and After
  • flash - Build Status Share data between requests
  • debug - Build Status show detail debug infomaton on log

获得帮助

案例

讨论

QQ群:369240307

License

This project is under BSD License. See the LICENSE file for the full license text.