Просмотр исходного кода

added single page application path.

master
Patrick Peng Sun 8 лет назад
Родитель
Сommit
d29312983b
1 измененных файлов: 9 добавлений и 5 удалений
  1. +9
    -5
      main.go

+ 9
- 5
main.go Просмотреть файл



//PathsConfig all system available pathes //PathsConfig all system available pathes
type PathsConfig struct { type PathsConfig struct {
Angular2App string `json:"angular2_app"`
Angular2App string `json:"angular2_app"`
SinglePageEdit string `json:"singlePageEdit"`
} }


//TODO: setup GlobalPath Config, from reading file
//GlobalPath all global pathes configurations //GlobalPath all global pathes configurations
// TODO: setup GlobalPath Config, from reading file
var GlobalPath = PathsConfig{ var GlobalPath = PathsConfig{
"/mnt/data/workspace/angular.ts/wechat/ng2-admin/dist/"}
"dist/",
"/mnt/data/workspace/go/src/wechat_hitxy/spa/",
}


//KFUsers info cache about current customer service //KFUsers info cache about current customer service
var KFUsers kfCache var KFUsers kfCache
http.HandleFunc("/iapi/createWechatQr", iapiCreateWechatQrCode) http.HandleFunc("/iapi/createWechatQr", iapiCreateWechatQrCode)
http.HandleFunc("/crmpixel.png", crmpixel) //tracking pixel. http.HandleFunc("/crmpixel.png", crmpixel) //tracking pixel.
http.HandleFunc("/crmcache", crmcache) http.HandleFunc("/crmcache", crmcache)
http.HandleFunc("/spa/editprofile", spaEditProfile)
http.ListenAndServe(":65500", nil) http.ListenAndServe(":65500", nil)
} }


http.ServeFile(w, r, GlobalPath.Angular2App+r.URL.Path[1:]) http.ServeFile(w, r, GlobalPath.Angular2App+r.URL.Path[1:])
}) })


//fs := http.FileServer(http.Dir("/mnt/data/workspace/angular.ts/ng2-admin/dist"))
//http.Handle("/test", http.StripPrefix("/test", fs))
fs := http.FileServer(http.Dir(GlobalPath.SinglePageEdit))
http.Handle("/spa/", http.StripPrefix("/spa", fs))


//fs := http.FileServer(http.Dir("/mnt/data/workspace/angular.ts/wechat/ng2-admin/dist")) //fs := http.FileServer(http.Dir("/mnt/data/workspace/angular.ts/wechat/ng2-admin/dist"))
//http.Handle("/", fs) //http.Handle("/", fs)

Загрузка…
Отмена
Сохранить