Skip to content

Instantly share code, notes, and snippets.

@yutakahashi114
Last active September 29, 2019 12:30
Show Gist options
  • Save yutakahashi114/f4ef513cb49087f4c6a039212d9c9901 to your computer and use it in GitHub Desktop.
Save yutakahashi114/f4ef513cb49087f4c6a039212d9c9901 to your computer and use it in GitHub Desktop.
package infrastructure
import (
"app/interfaces/controllers"
"github.com/gin-gonic/gin"
)
var Router *gin.Engine
func init() {
router := gin.Default()
userController := controllers.NewUserController(NewSqlHandler())
api := router.Group("/api")
{
api.POST("/users", func(c *gin.Context) { userController.Create(c) })
api.GET("/users/:id", func(c *gin.Context) { userController.Show(c) })
api.GET("/users", func(c *gin.Context) { userController.All(c) })
}
Router = router
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment