-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.go
48 lines (36 loc) · 1.32 KB
/
router.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package api
import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/sheacloud/cloud-inventory/internal/api/routes/aws"
"github.com/sheacloud/cloud-inventory/internal/db"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
)
// @title Cloud Inventory API
// @version 1.0
// @description Query Cloud Inventory
// @contact.name Jon Shea
// @contact.email cloud-inventory@sheacloud.com
// @license.name MIT
// @license.url https://opensource.org/licenses/MIT
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
// @BasePath /v1
func GetRouter(dao db.ReaderDAO) *gin.Engine {
router := gin.Default()
corsConfig := cors.DefaultConfig()
corsConfig.AllowOrigins = []string{"*", "https://cloud-inventory.sheacloud.com"}
corsConfig.AllowHeaders = []string{"*"}
router.Use(cors.New(corsConfig))
v1 := router.Group("/v1")
awsInventoryRouter := v1.Group("/inventory/aws")
awsDiffRouter := v1.Group("/diff/aws")
awsMetadataRouter := v1.Group("/metadata/aws")
aws.AddInventoryRoutes(awsInventoryRouter, dao)
aws.AddDiffRoutes(awsDiffRouter, dao)
aws.AddMetadataRoutes(awsMetadataRouter, dao)
router.GET("/docs/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
return router
}