Make sessions PUT and POST return the resulting Session

This commit is contained in:
Aaron Lindsay 2016-10-04 08:40:26 -04:00
parent d5b1260b27
commit 071b7ff1e3
1 changed files with 8 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"github.com/gorilla/securecookie"
"github.com/gorilla/sessions"
"log"
"net/http"
)
@ -96,13 +97,18 @@ func SessionHandler(w http.ResponseWriter, r *http.Request) {
DeleteSessionIfExists(r)
_, err = NewSession(w, r, dbuser.UserId)
session, err := NewSession(w, r, dbuser.UserId)
if err != nil {
WriteError(w, 999 /*Internal Error*/)
return
}
WriteSuccess(w)
err = session.Write(w)
if err != nil {
WriteError(w, 999 /*Internal Error*/)
log.Print(err)
return
}
} else if r.Method == "GET" {
s, err := GetSession(r)
if err != nil {