Преглед изворни кода

test strip prefix from url "/spa/" in this case to use the test directory

master
sp пре 4 година
родитељ
комит
d7ed3f6843
2 измењених фајлова са 15 додато и 15 уклоњено
  1. +2
    -2
      config.json
  2. +13
    -13
      main.go

+ 2
- 2
config.json Прегледај датотеку

"Host":"localhost", "Host":"localhost",
"Port":"8080", "Port":"8080",
"DocRoot": "./html/", "DocRoot": "./html/",
"StaticUrl": "/",
"StripPrefix" : "/"
"StaticUrl": "/spa/",
"StripPrefix" : "/spa/"
} }

+ 13
- 13
main.go Прегледај датотеку



func setupRootFileServer() { func setupRootFileServer() {


fs := http.FileServer(http.Dir(config.DocRoot))
fs := http.FileServer(http.Dir(config.DocRoot + "test"))
http.Handle(config.StaticUrl, http.StripPrefix(config.StripPrefix, fs)) http.Handle(config.StaticUrl, http.StripPrefix(config.StripPrefix, fs))


} }


func setupHTTPHandler() { func setupHTTPHandler() {
http.HandleFunc("/api", HelloHandler) http.HandleFunc("/api", HelloHandler)
http.HandleFunc("/upload", HelloHandler)
http.HandleFunc("/crmfiles/", HelloHandler)
http.HandleFunc("/dumprequest", HelloHandler)
http.HandleFunc("/MP_verify_6JqVkftKr39GMakA.txt", HelloHandler)
http.HandleFunc("/spa/redirect", HelloHandler)
http.HandleFunc("/iapi/getAccessToken", HelloHandler)
http.HandleFunc("/iapi/createWechatQr", HelloHandler)
http.HandleFunc("/crmpixel.png", HelloHandler) //tracking pixel.
http.HandleFunc("/crmcache", HelloHandler)
http.HandleFunc("/spa/editprofile", HelloHandler)
http.HandleFunc("/spa/livecast", HelloHandler)
http.HandleFunc("/spa/editmeeting", HelloHandler)
//http.HandleFunc("/upload", HelloHandler)
//http.HandleFunc("/crmfiles/", HelloHandler)
//http.HandleFunc("/dumprequest", HelloHandler)
//http.HandleFunc("/MP_verify_6JqVkftKr39GMakA.txt", HelloHandler)
//http.HandleFunc("/spa/redirect", HelloHandler)
//http.HandleFunc("/iapi/getAccessToken", HelloHandler)
//http.HandleFunc("/iapi/createWechatQr", HelloHandler)
//http.HandleFunc("/crmpixel.png", HelloHandler) //tracking pixel.
//http.HandleFunc("/crmcache", HelloHandler)
//http.HandleFunc("/spa/editprofile", HelloHandler)
//http.HandleFunc("/spa/livecast", HelloHandler)
//http.HandleFunc("/spa/editmeeting", HelloHandler)


log.Printf("Server started at %s:%s\n", config.Host, config.Port) log.Printf("Server started at %s:%s\n", config.Host, config.Port)
log.Fatal(http.ListenAndServe(config.Host+":"+config.Port, nil)) log.Fatal(http.ListenAndServe(config.Host+":"+config.Port, nil))

Loading…
Откажи
Сачувај