Tango is a micro & pluggable web framework for Go.
To install Tango:
go get gitea.com/lunny/tango
A classic usage of Tango below:
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()
}
Then visit http://localhost:8000
on your browser. You will get
{"say":"Hello tango!"}
If you change true
after if
to false
, then you will get
{"err":"something error"}
This code will automatically convert returned map or error to a json because we has an embedded struct tango.JSON
.
Middlewares allow you easily plugin features for your Tango applications.
There are already many middlewares to simplify your work:
This project is under BSD License. See the LICENSE file for the full license text.