// Always returns the index.html page. func IndexPage(w http.ResponseWriter, req *http.Request) { dashDir := getDashDir() if len(dashDir) != 0 { // Serve the index page from disk if the env variable is set. http.ServeFile(w, req, path.Join(dashDir, "index.html")) } else { // Otherwise serve it from the compiled resources. b, _ := resources.Asset("index.html") http.ServeContent(w, req, "index.html", time.Time{}, bytes.NewReader(b)) } return }
func memoryFileServer(w http.ResponseWriter, req *http.Request) { log.Debugf("[recv] %s %s [%s]", req.Method, req.URL.Path, req.RemoteAddr) upath := req.URL.Path b, err := resources.Asset(req.URL.Path) if err != nil { http.Error(w, upath+": File not found", http.StatusNotFound) return } http.ServeContent(w, req, upath, time.Time{}, bytes.NewReader(b)) return }
func memoryFileServer(w http.ResponseWriter, req *http.Request) { log.Debugf("[recv] %s %s [%s]", req.Method, req.URL.Path, req.RemoteAddr) upath := req.URL.Path if len(upath) == 0 { upath = "index.html" } // TODO: use the new mux to do this work dir, file := path.Split(upath) if file == "browser" || file == "stats" { file = file + ".html" } upath = path.Join(dir, file) b, err := resources.Asset(upath) if err != nil { http.Error(w, upath+": File not found", http.StatusNotFound) return } http.ServeContent(w, req, upath, time.Time{}, bytes.NewReader(b)) return }