1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-11-01 00:10:06 -04:00

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

View File

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