diff --git a/appServer.go b/appServer.go index 6dedae8..ab856da 100644 --- a/appServer.go +++ b/appServer.go @@ -155,6 +155,15 @@ func setSessionIDCookie(w http.ResponseWriter, sessionID int) { http.SetCookie(w, &cookie) } +func getSessionIDCookie(req *http.Request) (int, error) { + cookie, err := req.Cookie("session") + if err != nil { + return 0, err + } + + return strconv.Atoi(cookie.Value) +} + func (app *application) postHandler(w http.ResponseWriter, req *http.Request) { if reqBody, err := io.ReadAll(req.Body); err == nil { diff --git a/clientStorage.go b/clientStorage.go index a875b22..7aaaa43 100644 --- a/clientStorage.go +++ b/clientStorage.go @@ -44,6 +44,7 @@ func (session *sessionData) ClientStorage() ClientStorage { if session.clientStorage == nil { storage := new(clientStorageData) storage.bridge = session.bridge + storage.getResult = map[int]func(string, string){} session.clientStorage = storage } return session.clientStorage