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)

相关文章
相关标签/搜索