5.7 KiB
5.7 KiB
Tango 简体中文
Package tango is a micro-kernel & pluggable web framework for Go.
Current version: v0.2.8 Version History
Getting Started
To install Tango:
go get github.com/lunny/tango
The very basic usage of Tango:
package main
import "github.com/lunny/tango"
func main() {
t := tango.Classic()
t.Get("/", func() string {
return "Hello tango!"
})
t.Run()
}
Then visit http://localhost:8000
on your browser. Of course, tango support struct form also.
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()
}
This code will automatically convert returned map to a json because we has an embedded struct tango.Json
.
More document, please see godoc and Wiki
Features
- Powerful routing & Flexible routes combinations.
- Directly integrate with existing services.
- Easy to plugin/unplugin features with modular design.
- High performance dependency injection embedded.
Middlewares
Middlewares allow you easily plugin/unplugin features for your Tango applications.
There are already many middlewares to simplify your work:
- 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 - Session manager
- 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
Getting Help
Cases
License
This project is under BSD License. See the LICENSE file for the full license text.