add 404 handler for admin

This commit is contained in:
sentriz
2019-07-31 17:00:44 +01:00
parent 7580835146
commit e7c98808bb
6 changed files with 19 additions and 7 deletions

View File

@@ -134,13 +134,13 @@ func (c *Controller) H(h adminHandler) http.Handler {
if resp.data == nil {
resp.data = &templateData{}
}
session := r.Context().Value(key.Session).(*sessions.Session)
resp.data.Flashes = session.Flashes()
if err := session.Save(r, w); err != nil {
http.Error(w, fmt.Sprintf("saving session: %v", err), 500)
return
if session, ok := r.Context().Value(key.Session).(*sessions.Session); ok {
resp.data.Flashes = session.Flashes()
sessLogSave(w, r, session)
}
if user, ok := r.Context().Value(key.User).(*model.User); ok {
resp.data.User = user
}
resp.data.User, _ = r.Context().Value(key.User).(*model.User)
buff := c.buffPool.Get()
defer c.buffPool.Put(buff)
tmpl, ok := c.templates[resp.template]