4 Static
Lunny Xiao edited this page 2015-01-13 18:05:48 +08:00

Static lets you make an one line web server.

func main() {
    t := tango.New(tango.Static())
    t.Run()
}

Then, put your files on ./public folder. You can visit them directly. For example:

http://localhost/images/logo.png  --> ./public/images/logo.png

Of course, you can add yourself handler to specify the process.

func main() {
    t := tango.New()
    t.Use(AuthHandler)
    t.Use(tango.Static())
    t.Run()
}

Of course, you can use StaticOptions to custom your static, for example:

t.Use(tango.Static(tango.StaticOptions{Prefix:"static"}))