-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (34 loc) · 996 Bytes
/
main.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
package main
import (
"log"
"github.com/gin-contrib/cors"
"github.com/loupeznik/better-wapi/docs"
"github.com/gin-gonic/gin"
"github.com/loupeznik/better-wapi/src/api"
"github.com/loupeznik/better-wapi/src/helpers"
)
// @title Better WAPI
// @version 1.0
// @description A wrapper around the Wedos API (WAPI)
// @license.name GNU General Public License v3.0
// @license.url https://github.com/Loupeznik/better-wapi/blob/master/LICENSE
// @BasePath /api
// @host http://localhost:8000
func main() {
router := gin.Default()
config := helpers.SetupIntegrationConfig()
if config.BaseUrl != "" {
docs.SwaggerInfo.Host = config.BaseUrl
}
corsConfig := cors.DefaultConfig()
corsConfig.AllowAllOrigins = true
corsConfig.AllowCredentials = true
corsConfig.AllowHeaders = []string{"*"}
corsConfig.AddAllowMethods("OPTIONS")
router.Use(cors.New(corsConfig))
api.SetupRoutes(router)
err := router.Run("0.0.0.0:8000")
if err != nil {
log.Fatal("Could not start router")
}
}