You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
4 years ago | |
---|---|---|
README.md | 6 years ago | |
circle.yml | 4 years ago | |
dispatch.go | 6 years ago | |
dispatch_test.go | 6 years ago |
README.md
Dispatch

Dispacth is a handler for dipatch http request according url's prefix.
Example
import (
"github.com/lunny/tango"
"github.com/tango-contrib/dispatch"
)
func main() {
logger := tango.NewLogger(os.Stdout)
t1 := tango.NewWithLog(logger)
t2 := tango.NewWithLog(logger)
dispatch := dispatch.New(map[string]*tango.Tango{
"/": t1,
"/api/": t2,
})
t3 := tango.NewWithLog(logger)
t3.Use(dispatch)
t3.Run(":8000")
}
package main
import (
"github.com/Unknwon/macaron"
"github.com/lunny/tango"
"github.com/tango-contrib/dispatch"
)
func main() {
t := tango.Classic()
t.Any("/favicon.ico", func(self *tango.Context) {
self.Redirect("/static/favicon.ico", 301)
})
t.Any("/", func() string {
return "Hello Tango!"
})
m := macaron.Classic()
m.Get("/", func(ctx *macaron.Context) string {
return "Macaron on Tango!"
})
dispatch := dispatch.Use("/", t)
dispatch.Add("/m/", m)
tan := tango.Classic()
tan.Use(dispatch)
tan.Run(80)
}