feat(Go-StudyExample): 2020/12/9 :新增Gin框架使用示例

This commit is contained in:
Huangzj
2020-12-09 09:45:46 +08:00
parent 9ad10e8cd9
commit 1361db0274
22 changed files with 881 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
/*
* @Author : huangzj
* @Time : 2020/12/8 15:27
* @Description
*/
package gin
import (
"fmt"
"github.com/gin-gonic/gin"
"testing"
)
func TestReadCookie(t *testing.T) {
router := gin.Default()
router.GET("/cookie", func(c *gin.Context) {
//read note 这边需要web前端发送对应的cookie
cookie, err := c.Cookie("gin_cookie")
//read note 设置对应值的cookie
if err != nil {
cookie = "NotSet"
c.SetCookie("gin_cookie", "test", 3600, "/", "localhost", false, true)
}
fmt.Printf("Cookie value: %s \n", cookie)
})
_ = router.Run()
}