goalng 如何利用mux写一个文件服务器

hz_wujun · 2013-11-27 08:25:41 · 6020 次点击
polaris
社区,需要你我一同完善!

这种的还是别交给 mux 处理了。

另外,mux 定义路由之后,需要加一句:http.Handle("/", r)

#1
更多评论
    muxRouter := mux.NewRouter()
    muxRouter.HandleFunc("/", router.IndexHandleFunc)

        serveMux := http.DefaultServeMux
    serveMux.Handle("/", muxRouter)
    serveMux.HandleFunc("/statics/", router.StaticsHandleFunc)

        httpServer := http.Server{
        Addr:           ":12345",
        Handler:        serveMux,
        ReadTimeout:    10 * time.Second,
        WriteTimeout:   10 * time.Second,
        MaxHeaderBytes: 1 << 20,
    }
        httpServer.ListenAndServe()
#2

linux下不能运行,是什么原因呢

#3