福利视频在线,麻豆久久久久久久,午夜免费久久久久http://www.aygfsteel.com/willpower88/category/55345.html對JAVA有點(diǎn)理解了……zh-cnWed, 07 Feb 2024 01:39:26 GMTWed, 07 Feb 2024 01:39:26 GMT60gland debug. Got a connection, launched process http://www.aygfsteel.com/willpower88/archive/2024/02/04/451359.html一凡一凡Sun, 04 Feb 2024 05:57:00 GMThttp://www.aygfsteel.com/willpower88/archive/2024/02/04/451359.htmlhttp://www.aygfsteel.com/willpower88/comments/451359.htmlhttp://www.aygfsteel.com/willpower88/archive/2024/02/04/451359.html#Feedback0http://www.aygfsteel.com/willpower88/comments/commentRss/451359.htmlhttp://www.aygfsteel.com/willpower88/services/trackbacks/451359.html解決辦法,重新安裝xcode  
rm -rf /Library/Developer/CommandLineTools
xcode
-select --install


一凡 2024-02-04 13:57 發(fā)表評論
]]>
gin跨域http://www.aygfsteel.com/willpower88/archive/2019/12/26/434991.html一凡一凡Thu, 26 Dec 2019 03:17:00 GMThttp://www.aygfsteel.com/willpower88/archive/2019/12/26/434991.htmlhttp://www.aygfsteel.com/willpower88/comments/434991.htmlhttp://www.aygfsteel.com/willpower88/archive/2019/12/26/434991.html#Feedback0http://www.aygfsteel.com/willpower88/comments/commentRss/434991.htmlhttp://www.aygfsteel.com/willpower88/services/trackbacks/434991.html
  • 新增中間件cors
  • func Cors() gin.HandlerFunc {
    return func(c *gin.Context) {
    method := c.Request.Method

    c.Header("Access-Control-Allow-Origin", "*") //必選
         c.Header("Access-Control-Allow-Headers", "*") //可選 如果request有header, 必選
         //c.Header("Access-Control-Allow-Credentials", "true") //可選
    //c.Header("Access-Control-Allow-Methods", "*") //可選
    //c.Header("Access-Control-Expose-Headers", "*") //可選

    //放行所有OPTIONS方法
    if method == "OPTIONS" {
    c.AbortWithStatus(http.StatusOK)
    }
    // 處理請求
    c.Next()
    }
    }
  • 在router里增加cors,必須在group之前,全局設(shè)置
    r.Use(gin.Logger(), gin.Recovery(), cors.Cors())
  • 測試代碼,header設(shè)置不能多于cors設(shè)置
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    </head>
    <link type="test/css" href="css/style.css" rel="stylesheet">
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    <script type="text/javascript">
    $(function(){
    $("#cors").click(
    function(){
    $.ajax({
    headers:{
    "Content-Type":"application/json;charset=UTF-8",
    "Access":"adsad",
    "Access-Token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3QiLCJwYXNzd29yZCI6InRlc3QxMjM0NTYiLCJleHAiOjE1NzczMzY3MTIsImlzcyI6Imdpbi1ibG9nIn0.wMlQXqZO2V0LR-FIgDh45LWI0OYMYi6an_NvRmF0Nug"
    },
    url:"http://127.0.0.1:8000/api/v1/articles",
    success:function(data){
    console.log("start");
    console.log(data);
    }
    })
    });
    });
    </script>
    <body>
    <input type="button" id="cors" value="core跨域測試">
    </body>
    </html>
  • 請求的headers數(shù)量、名稱與cors里的設(shè)置需要嚴(yán)格對應(yīng),不然報(bào)錯如下
    Access to XMLHttpRequest at 'http://127.0.0.1:8000/api/v1/articles' from origin 'http://localhost:9999' has been blocked by CORS policy: Request header field access is not allowed by Access-Control-Allow-Headers in preflight response.


  • 一凡 2019-12-26 11:17 發(fā)表評論
    ]]>
    gin-swagger鑒權(quán)(auth)http://www.aygfsteel.com/willpower88/archive/2019/12/23/434981.html一凡一凡Mon, 23 Dec 2019 08:08:00 GMThttp://www.aygfsteel.com/willpower88/archive/2019/12/23/434981.htmlhttp://www.aygfsteel.com/willpower88/comments/434981.htmlhttp://www.aygfsteel.com/willpower88/archive/2019/12/23/434981.html#Feedback0http://www.aygfsteel.com/willpower88/comments/commentRss/434981.htmlhttp://www.aygfsteel.com/willpower88/services/trackbacks/434981.htmlin header 說明參數(shù)放在header,你的鑒權(quán)代碼需要從header中獲取

    // @title gin-blog API
    // @version 0.0.1
    // @description This is a gin blog example
    // @securityDefinitions.apikey ApiKeyAuth
    // @in header
    // @name token
    // @BasePath /

    2、在具體的handler里添加如下注釋,此處的ApiKeyAuth和main中的apike對應(yīng),切記不要修改
    // @Security ApiKeyAuth

    3、swagger頁面如下:


    4、添加token后,后續(xù)所有有鑒權(quán)接口的header里自動攜帶token


    一凡 2019-12-23 16:08 發(fā)表評論
    ]]>
    主站蜘蛛池模板: 娄烦县| 健康| 平乐县| 论坛| 泰和县| 双柏县| 龙川县| 宁海县| 措勤县| 军事| 永嘉县| 伊宁县| 荣成市| 浪卡子县| 乌苏市| 萨迦县| 寿宁县| 明水县| 兴国县| 九台市| 吉水县| 陵川县| 呈贡县| 岗巴县| 金阳县| 宜城市| 建平县| 梁河县| 宣城市| 芷江| 清水县| 永德县| 沧源| 巴塘县| 定结县| 吕梁市| 池州市| 汝城县| 千阳县| 丹凤县| 家居|