0
1

More than 1 year has passed since last update.

[Golang]APIのバージョン管理

Posted at
main.go
package main

import (
	"fmt"

	"github.com/gin-gonic/gin"
	"example/webapp/api/v1"
)

r := gin.Default()

func main() {
    r := gin.Default()
    v1.GroupRouter(r)

	r.Run()

}
urls.go

package v1

import (
	"fmt"
	"github.com/gin-gonic/gin"
	
)

func ApiTemp(router *gin.RouterGroup) {
	router.GET("/ping", func(c *gin.Context) {
		// queryparamerの値を取得する
		// fmt.Println(c.Query("samplequery"))
		c.JSON(200, gin.H{
			"Message": "v1 ping healthcheck",
		})
	})
}



func GroupRouter(check *gin.Engine){
	check.GET("/healthcheckcheck", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "healthcheckcheck",
		})
	})
	v1_path := check.Group("/v1")
	ApiTemp(v1_path)

}

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1