mirror of https://github.com/anoshenko/rui.git
Optimisation
This commit is contained in:
parent
a8679fbd26
commit
e9b128bc35
|
|
@ -155,6 +155,15 @@ func setSessionIDCookie(w http.ResponseWriter, sessionID int) {
|
||||||
http.SetCookie(w, &cookie)
|
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) {
|
func (app *application) postHandler(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
if reqBody, err := io.ReadAll(req.Body); err == nil {
|
if reqBody, err := io.ReadAll(req.Body); err == nil {
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ func (session *sessionData) ClientStorage() ClientStorage {
|
||||||
if session.clientStorage == nil {
|
if session.clientStorage == nil {
|
||||||
storage := new(clientStorageData)
|
storage := new(clientStorageData)
|
||||||
storage.bridge = session.bridge
|
storage.bridge = session.bridge
|
||||||
|
storage.getResult = map[int]func(string, string){}
|
||||||
session.clientStorage = storage
|
session.clientStorage = storage
|
||||||
}
|
}
|
||||||
return session.clientStorage
|
return session.clientStorage
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue