<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          cedar-sessioncedar-router 的 session 組件

          聯(lián)合創(chuàng)作 · 2023-10-01 11:23

          cedar-router 的一個(gè) session 組件。

          2 個(gè)方法

          • Set(string,interface{})
          • Get(string) interface{}

          使用方法

          r:=cedar.NewRouter()

          x := cedar_session.NewSession(r)

          x 繼承所有的 http method 和 group ,只是有些小改動(dòng) ,不能直接使用 ,只能在 http method 中使用

          從之前的 

          r.Get("/",func(w http.ResponseWriter, r *http.Request,nil)
          r.Group("/a", func(groups *cedar.Groups) {}

          到現(xiàn)在的

          x.Get("/", func(w http.ResponseWriter, r *http.Request, s cedar_session.Session), nil)
          x.Group("/a", func(groups *cedar_session.TheGroup) {}

          改了參數(shù) ,更多 例子 ,現(xiàn)在使用的是系統(tǒng)自帶的map ,可能以后會(huì)換成 spruce ,分布式的kv數(shù)據(jù)庫(kù)

          例子

          r := cedar.NewRouter()
          x := cedar_session.NewSession(r)
          x.Get("/set", func(w http.ResponseWriter, r *http.Request, s cedar_session.Session) {
          	s.Set("hello", "world"+r.RemoteAddr) // 設(shè)置session
              s.Get("hello")                       // 獲取session
          	w.Write([]byte("hello session"))
          }, nil)

           

          瀏覽 22
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  97超碰在线播放 | 在线高清无码观看 | 人人操,人人 | 国产免费aaa高清 | 亚洲精品久久久久 |