6
Tango
Lunny Xiao edited this page 2019-11-27 01:04:24 +00:00
Tango
is the entry of all things. For a general usage, you just need use Classic
, it will satisfy many of your requirement.
func main() {
t := tango.Classic()
t.Use(...)
t.Get(...)
t.Run()
}
The default tango has a default Logger, it will output the logs to io.StdOut. If you want to custom it, you can give a logger param.
import "gitea.com/lunny/log"
l := log.New(out, "[tango] ", log.Ldefault())
l.SetOutputLevel(log.Ldebug)
t := tango.Classic(l)
Classic accepts a Logger
interface, you should implement Debug
, Warn
, Error
methods.
If you only want to make a static web server, just:
func main() {
t := tango.New(tango.Static(tango.StaticOptions{Prefix:"public"}))
t.Run()
}
then put your files on ./public
folder, and you can visit them directly as a public
prefix.
If you want to custom your Logger library, you can use:
NewWithLog(Logger, ...tango.Handler)