12345678910111213141516171819202122232425262728 |
- package router
- import (
- "github.com/gin-gonic/gin"
- "goiot-cronapi/controllers"
- "gopkg"
- )
- func InitRouter() *gin.Engine {
- // Creates a gin router with default middleware:
- // logger and recovery (crash-free) middleware
- router := gin.Default()
- g := router.Group("/api")
- g.Use(gin.Recovery())
- g.Use(gopkg.CORSMiddleware())
- // use ginSwagger middleware to
- //router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
- // Cron
- //g.POST("/cron/sample", controllers.Sample)
- //g.POST("/cron/consume", controllers.Consume)
- g.POST("/cron/weather", controllers.WeatherSample)
- return router
- }
|