frontend: Add -simulator option to serve file without nginx (usefull for some development purposes)

This commit is contained in:
nemunaire 2018-08-17 20:31:06 +02:00 committed by Pierre-Olivier Mercier
commit baf12f87a3
2 changed files with 56 additions and 0 deletions

25
frontend/static.go Normal file
View file

@ -0,0 +1,25 @@
package main
import (
"net/http"
"os"
"path"
)
var staticDir = "static"
func serveIndex(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, path.Join(staticDir, "index.html"))
}
type TeamMyServer struct {
path2Dir string
}
func (s TeamMyServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if _, err := os.Stat(startedFile); os.IsNotExist(err) {
http.ServeFile(w, r, path.Join(s.path2Dir, "wait.json"))
} else {
http.ServeFile(w, r, path.Join(s.path2Dir, "my.json"))
}
}