package panelui import ( "net/http" "github.com/GeertJohan/go.rice" ) var templates, static *rice.Box func init() { templates = rice.MustFindBox("res/templates") static = rice.MustFindBox("res/static") } // GetMux returns a ready-to-use mux func GetMux() *http.ServeMux { mux := http.NewServeMux() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { user := r.Context().Value(keyUser) if user == nil { panic("Authentication middleware failed!") } templateExecute(w, r, "home.html", templates, map[string]interface{}{"User": user}) }) mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(static.HTTPBox()))) return mux }