1
0
Fork 0
forked from boyska/feedpanel
feedpanel/panelui/main.go

30 lines
678 B
Go
Raw Permalink Normal View History

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})
})
2018-11-13 15:09:33 +01:00
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(static.HTTPBox())))
return mux
}