go--http

静态服务器

import {

    "net/http"

}

//for get static file
var gStaticHandler http.Handler

// need static file
func hFuncStatic(w http.ResponseWriter, req *http.Request) {
    fmt.Println("static")
    gStaticHandler.ServeHTTP(w, req)

}

    //init static handler
    gStaticHandler = http.FileServer(http.Dir(gConfig.VisitRoot))

    //http server

    http.HandleFunc("/", hFuncStatic)






猜你喜欢

转载自blog.csdn.net/evsqiezi/article/details/80848216