()
| 78 | } |
| 79 | |
| 80 | func CreateApiServer() *gin.Engine { |
| 81 | // Create router |
| 82 | router := gin.Default() |
| 83 | |
| 84 | // Enable CORS |
| 85 | // cfg := basicRes.GetConfigReader() |
| 86 | // router.Use(cors.New(cors.Config{ |
| 87 | // // Allow all origins |
| 88 | // AllowOrigins: cfg.GetStringSlice("CORS_ALLOW_ORIGIN"), |
| 89 | // // Allow common methods |
| 90 | // AllowMethods: []string{"PUT", "PATCH", "POST", "GET", "OPTIONS"}, |
| 91 | // // Allow common headers |
| 92 | // AllowHeaders: []string{"Origin", "Content-Type"}, |
| 93 | // // Expose these headers |
| 94 | // ExposeHeaders: []string{"Content-Length"}, |
| 95 | // // Allow credentials |
| 96 | // AllowCredentials: false, |
| 97 | // // Cache for 2 hours |
| 98 | // MaxAge: 120 * time.Hour, |
| 99 | // })) |
| 100 | |
| 101 | // For both protected and unprotected routes |
| 102 | router.GET("/ping", ping.Get) |
| 103 | router.GET("/ready", ping.Ready) |
| 104 | router.GET("/health", ping.Health) |
| 105 | router.GET("/version", version.Get) |
| 106 | |
| 107 | // Api keys |
| 108 | router.Use(RestAuthentication(router, basicRes)) |
| 109 | router.Use(OAuth2ProxyAuthentication(basicRes)) |
| 110 | |
| 111 | return router |
| 112 | } |
| 113 | |
| 114 | func SetupApiServer(router *gin.Engine) { |
| 115 | // Set gin mode |
no test coverage detected