Micro & pluggable web framework for Go
|
||
---|---|---|
.gitea/workflows | ||
public | ||
.gitignore | ||
compress_test.go | ||
compress.go | ||
context_test.go | ||
context.go | ||
cookie_test.go | ||
cookie.go | ||
doc.go | ||
error_test.go | ||
error.go | ||
file_test.go | ||
file.go | ||
form_test.go | ||
form.go | ||
go.mod | ||
go.sum | ||
group_test.go | ||
group.go | ||
handler_test.go | ||
LICENSE | ||
logger_test.go | ||
logger.go | ||
logo.png | ||
param_test.go | ||
param.go | ||
pool_test.go | ||
pool.go | ||
prefix_test.go | ||
prefix.go | ||
query_test.go | ||
query.go | ||
README_CN.md | ||
README.md | ||
recovery_test.go | ||
recovery.go | ||
RELEASE.md | ||
response.go | ||
return_test.go | ||
return.go | ||
router_test.go | ||
router.go | ||
static_test.go | ||
static.go | ||
tan_test.go | ||
tan.go |
Tango 简体中文
Package tango is a micro & pluggable web framework for Go.
Getting Started
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
.
Features
- Powerful routing & Flexible routes combinations.
- Directly integrate with existing services.
- Easy to plugin features with modular design.
- High performance dependency injection embedded.
Middlewares
Middlewares allow you easily plugin 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
- 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
Documentation
- 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
Discuss
- Google Group - English
- QQ Group - 简体中文 #369240307
Cases
- GopherTC - China Discuss Forum
- Wego - Discuss Forum
- dbweb - DB management web UI
- Godaily - gitea
- Pugo - A pugo blog
- Gos - Static web server
- GoFtpd - Pure Go cross-platform ftp server
License
This project is under BSD License. See the LICENSE file for the full license text.