dashboard: move public.json files into a dedicated directory

This commit is contained in:
nemunaire 2018-12-06 03:46:14 +01:00
commit 7970b552e9
5 changed files with 25 additions and 22 deletions

View file

@ -20,6 +20,7 @@ import (
)
var StaticDir string
var DashboardDir string
var TeamsDir string
type ResponseWriterPrefix struct {
@ -67,6 +68,7 @@ func main() {
var bind = flag.String("bind", "127.0.0.1:8082", "Bind port/socket")
var baseURL = flag.String("baseurl", "/", "URL prepended to each URL")
flag.StringVar(&StaticDir, "static", "./htdocs-dashboard/", "Directory containing static files")
flag.StringVar(&DashboardDir, "dashbord", "./DASHBOARD", "Base directory where save public JSON files")
flag.StringVar(&TeamsDir, "teams", "./TEAMS", "Base directory where save teams JSON files")
flag.StringVar(&settings.SettingsDir, "settings", settings.SettingsDir, "Base directory where load and save settings")
flag.Parse()

View file

@ -61,46 +61,46 @@ func init() {
api.Router().GET("/public.json", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Header().Set("Cache-Control", "no-cache")
http.ServeFile(w, r, path.Join(TeamsDir, "public", "public.json"))
http.ServeFile(w, r, path.Join(DashboardDir, "public.json"))
})
api.Router().GET("/public0.json", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Header().Set("Cache-Control", "no-cache")
http.ServeFile(w, r, path.Join(TeamsDir, "public", "public0.json"))
http.ServeFile(w, r, path.Join(DashboardDir, "public0.json"))
})
api.Router().GET("/public1.json", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Header().Set("Cache-Control", "no-cache")
http.ServeFile(w, r, path.Join(TeamsDir, "public", "public1.json"))
http.ServeFile(w, r, path.Join(DashboardDir, "public1.json"))
})
api.Router().GET("/public2.json", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Header().Set("Cache-Control", "no-cache")
http.ServeFile(w, r, path.Join(TeamsDir, "public", "public2.json"))
http.ServeFile(w, r, path.Join(DashboardDir, "public2.json"))
})
api.Router().GET("/public3.json", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Header().Set("Cache-Control", "no-cache")
http.ServeFile(w, r, path.Join(TeamsDir, "public", "public3.json"))
http.ServeFile(w, r, path.Join(DashboardDir, "public3.json"))
})
api.Router().GET("/public4.json", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Header().Set("Cache-Control", "no-cache")
http.ServeFile(w, r, path.Join(TeamsDir, "public", "public4.json"))
http.ServeFile(w, r, path.Join(DashboardDir, "public4.json"))
})
api.Router().GET("/public5.json", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Header().Set("Cache-Control", "no-cache")
http.ServeFile(w, r, path.Join(TeamsDir, "public", "public5.json"))
http.ServeFile(w, r, path.Join(DashboardDir, "public5.json"))
})
api.Router().GET("/public6.json", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Header().Set("Cache-Control", "no-cache")
http.ServeFile(w, r, path.Join(TeamsDir, "public", "public6.json"))
http.ServeFile(w, r, path.Join(DashboardDir, "public6.json"))
})
api.Router().GET("/public7.json", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Header().Set("Cache-Control", "no-cache")
http.ServeFile(w, r, path.Join(TeamsDir, "public", "public7.json"))
http.ServeFile(w, r, path.Join(DashboardDir, "public7.json"))
})
api.Router().GET("/public8.json", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Header().Set("Cache-Control", "no-cache")
http.ServeFile(w, r, path.Join(TeamsDir, "public", "public8.json"))
http.ServeFile(w, r, path.Join(DashboardDir, "public8.json"))
})
api.Router().GET("/public9.json", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Header().Set("Cache-Control", "no-cache")
http.ServeFile(w, r, path.Join(TeamsDir, "public", "public9.json"))
http.ServeFile(w, r, path.Join(DashboardDir, "public9.json"))
})
}