Update API

- Return static silences json
- use http.ServeFile
This commit is contained in:
stuart nelson 2016-11-06 15:21:36 +01:00
parent 160a549150
commit 54251af063

32
main.go
View File

@ -18,37 +18,15 @@ func main() {
flag.Parse()
http.HandleFunc("/script.js", func(w http.ResponseWriter, r *http.Request) {
f, err := os.Open("dist/script.js")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
defer f.Close()
fs, err := f.Stat()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
http.ServeContent(w, r, "script.js", fs.ModTime(), f)
http.ServeFile(w, r, "dist/script.js")
})
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
f, err := os.Open("index.html")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
defer f.Close()
http.ServeFile(w, r, "index.html")
})
fs, err := f.Stat()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
http.ServeContent(w, r, "index", fs.ModTime(), f)
http.HandleFunc("/api/v1/silences", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "silences.json")
})
// Recompile the elm code whenever a change is detected.