Almost there

This commit is contained in:
Daniel Ledda
2020-11-14 15:18:30 +01:00
parent 59e6bf85f0
commit 140fdfe418

View File

@@ -13,15 +13,15 @@ import (
"time" "time"
) )
const ROOT_URL = "/climate" const ROOT_URL = "/climate/"
func startServer() { func startServer() {
port := "8001" port := "8001"
router := mux.NewRouter().StrictSlash(true) router := mux.NewRouter().StrictSlash(true)
router.HandleFunc("", showCharts).Methods("GET") router.HandleFunc("/show", showCharts).Methods("GET")
router.HandleFunc("", showCharts).Methods("GET").Queries("show-minutes", "{[0-9]+}") router.HandleFunc("/show", showCharts).Methods("GET").Queries("show-minutes", "{[0-9]+}")
router.HandleFunc("", saveSnapshot).Methods("POST")
router.HandleFunc("/data", sendData).Methods("GET") router.HandleFunc("/data", sendData).Methods("GET")
router.HandleFunc("/data", saveSnapshot).Methods("POST")
router.HandleFunc("/data", sendData).Methods("GET").Queries("since", "") router.HandleFunc("/data", sendData).Methods("GET").Queries("since", "")
router.HandleFunc("/data/now", createAndSendSnapshot).Methods("GET") router.HandleFunc("/data/now", createAndSendSnapshot).Methods("GET")
router.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("webapp/dist/")))) router.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("webapp/dist/"))))