Relocated ShowHub from articles.go to sessions.go because it has even less to do with articles than with sessions
This commit is contained in:
parent
8115c50974
commit
77e8edbe16
@ -23,25 +23,6 @@ const (
|
|||||||
PreviewMode
|
PreviewMode
|
||||||
)
|
)
|
||||||
|
|
||||||
func ShowHub(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
session, err := getSession(w, r, c, s)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
session.Values["article"] = nil
|
|
||||||
if err = session.Save(r, w); err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
|
||||||
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", session.Values["role"].(int))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func WriteArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
func WriteArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
session, err := getSession(w, r, c, s)
|
session, err := getSession(w, r, c, s)
|
||||||
|
@ -107,3 +107,22 @@ func Logout(c *b.Config, s *b.CookieStore) http.HandlerFunc {
|
|||||||
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", nil)
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ShowHub(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
session, err := getSession(w, r, c, s)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
session.Values["article"] = nil
|
||||||
|
if err = session.Save(r, w); err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", session.Values["role"].(int))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user