Sessions with gorilla

This commit is contained in:
Las Zenow 2012-08-18 02:06:43 +02:00
parent 44114bd91d
commit c513344169
15 changed files with 251 additions and 47 deletions

View file

@ -42,18 +42,26 @@ func storeFile(r *http.Request) error {
return nil
}
type uploadData struct {
S Status
Msg string
}
func uploadHandler(coll *mgo.Collection) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
status := ""
var data uploadData
data.S.User = SessionUser(r)
data.S.Upload = true
data.Msg = ""
if r.Method == "POST" {
err := storeFile(r)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
status = "Upload successful."
data.Msg = "Upload successful."
}
loadTemplate(w, "upload", status)
loadTemplate(w, "upload", data)
}
}