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

来源:互联网 发布:小学英语课堂软件 编辑:程序博客网 时间:2024/05/15 07:44
<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)
    })
}

                                             
1 0
原创粉丝点击