多Tango实例

Dispacth中间件可以通过前缀来分派请求到不同的Tango中。

示例

  1. import (
  2. "github.com/lunny/tango"
  3. "github.com/tango-contrib/dispatch"
  4. )
  5. func main() {
  6. logger := tango.NewLogger(os.Stdout)
  7. t1 := tango.NewWithLog(logger)
  8. t2 := tango.NewWithLog(logger)
  9. dispatch := dispatch.New(map[string]*tango.Tango{
  10. "/": t1,
  11. "/api/": t2,
  12. })
  13. t3 := tango.NewWithLog(logger)
  14. t3.Use(dispatch)
  15. t3.Run(":8000")
  16. }