亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

golang go-endpoints Session 使用 gorilla-toolkit

golang go-endpoints Session 使用 gorilla-toolkit

Go
胡說叔叔 2021-09-21 20:50:52
我正在嘗試實現會話處理并將其與 go-endpoints 包結合起來!我用來處理會話的包是 Gorilla Sessions (github.com/gorilla/sessions),我需要一些幫助..我能夠將 cookie 存儲到客戶端 .. 并且當我調用端點時可以看到 cookie 被發送到服務器。當我嘗試在調用 api 時從 Session 存儲中獲取 Session 值時出現的問題,我不能被扔到 cookie .. 它接縫是端點包從額外的內容或其他內容中剝離了 http.Request .. ?我嘗試獲取 cookie 的地方是在 Server.go 中func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request){     var store = sessions.NewCookieStore([]byte("secret123"));     session, _ := store.Get(r, "session-name");     // Get the previously flashes, if any.     c.Infof("foo value is : %v",r.Cookies());     if flashes := session.Flashes(); len(flashes) > 0 {     // Just print the flash values.     c.Infof("this is the testing post message with cookie from the ServeHTTP    :       %v",flashes);      }       else {      // Set a new flash.      session.AddFlash("Hello, flash messages world!")      c.Infof("No flashes found.");      }      session.Save(r, w)      }我得到的是一個空數組....:(有人有線索嗎?謝謝 ?。。。。?
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 176 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號