Gin #
アドレスの指定 #
router := gin.Default()
router.GET("/albums", getAlbums)
router.GET("/albums/:id", getAlbumByID)
router.POST("/albums", postAlbums)
router.Run("0.0.0.0:8080")
“localhost:8080"などとしておくと、外部からアクセスできない。 “0.0.0.0:8080"としすればよい。
リダイレクト #
router.GET("/login", func(c *gin.Context) {
c.Redirect(http.StatusMovedPermanently, config.AuthCodeURL("state"))
})
URLのQuery文字列の取得 #
code := c.Query("code")
Queryがないときは”"(空の文字列)が返る。