Skip to content

Instantly share code, notes, and snippets.

@dipeshhkc
Created December 30, 2022 23:08
Show Gist options
  • Save dipeshhkc/8ccd474541861eff41803b9af1de3925 to your computer and use it in GitHub Desktop.
Save dipeshhkc/8ccd474541861eff41803b9af1de3925 to your computer and use it in GitHub Desktop.
//SetupRoutes : gin router
func SetupRoutes() {
httpRouter := gin.Default()
//handling CORS
httpRouter.Use(cors.New(cors.Config{
AllowOrigins: []string{"*"},
AllowMethods: []string{"PUT", "PATCH", "GET", "POST", "OPTIONS", "DELETE"},
AllowHeaders: []string{"*"},
AllowCredentials: true,
}))
httpRouter.GET("/", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"data": "Golang RabbitMQ API 📺 Up and Running"})
})
httpRouter.POST("task1", controller.Task1Controller)
httpRouter.POST("task2", controller.Task2Controller)
httpRouter.Run(constants.SERVERPORT)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment