Simplify the setup of bundled assets (#436)
1. Move the generated file to handlers - it better belongs there 2. Ensure that all file serves are also handled by the asset store Co-authored-by: Marcos Lilljedahl <marcosnils@gmail.com>
This commit is contained in:
@@ -3,7 +3,6 @@ package handlers
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
@@ -34,12 +33,17 @@ func Home(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
index := filepath.Join("./www", playground.AssetsDir, "/index.html")
|
||||
if _, err := os.Stat(index); os.IsNotExist(err) {
|
||||
index = "./www/default/index.html"
|
||||
index, err := Asset(filepath.Join(playground.AssetsDir, "/index.html"))
|
||||
if err != nil {
|
||||
index, err = Asset("default/index.html")
|
||||
}
|
||||
|
||||
http.ServeFile(w, r, index)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusFound)
|
||||
return
|
||||
|
||||
}
|
||||
w.Write(index)
|
||||
}
|
||||
|
||||
func Landing(rw http.ResponseWriter, req *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user