您的位置:首页 > 理论基础 > 计算机网络

GO1.5标准包http.FileServer的拔高用法.

2015-08-31 20:45 465 查看
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#0000ff;">package</span><span style=" color:#f57900;"> </span>main


import (

    "fmt"

    "net/http"

)


func main() {

    h := http.FileServer(http.Dir("./"))

    http.ListenAndServe(":1789", ce(h))


}


func ce(h http.Handler) http.Handler {

    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

        fmt.Println(r.URL.Path)

        h.ServeHTTP(w, r)

    })

}



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息