鍍金池/ 問(wèn)答/PHP  GO/ golang echo 有木有 像 gin 一樣 有個(gè) gin.H

golang echo 有木有 像 gin 一樣 有個(gè) gin.H

golang 的 echo 有木有

c.JSON(http.StatusBadRequest, gin.H{
    "status":  "error",
    "message": "創(chuàng)建失敗",
})


gin.H

回答
編輯回答
柒喵

type H map[string]interface{}
不管是gin還是echo,Json的第二個(gè)參數(shù)都是interface,你就自己將 map[string]interface{}定義成H就可以了。。。

2017年5月13日 18:04
編輯回答
你的瞳

type H map[string]interface{}
這個(gè) H 就是個(gè) map[string]interface{}

func HttpTestCtx(ctx echo.Context) error {
    return ctx.JSON(http.StatusBadRequest, map[string]interface{}{
        "status":  "error",
        "message": "創(chuàng)建失敗",
    })
}

這樣就可以了

2018年4月13日 03:00