-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (44 loc) · 1.56 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"time"
"github.com/hoxito/mysql_comparer/rest/routes"
"github.com/hoxito/mysql_comparer/tools/env"
docs "github.com/hoxito/mysql_comparer/docs"
"github.com/hoxito/mysql_comparer/rest/middlewares"
swaggerfiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
"github.com/gin-gonic/gin"
cors "github.com/itsjamie/gin-cors"
)
// @title Swagger Diff API
// @version 1.0
// @description This is a database differenciator API.
// @termsOfService http://swagger.io/terms/
// @contact.name jose aranciba
// @contact.email support@swagger.io
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host localhost:3010
// @securityDefinitions.basic BasicAuth
func main() {
router := gin.Default()
docs.SwaggerInfo.BasePath = "/v1"
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
routes.ComprarerRoute(router)
router.Use(middlewares.ErrorHandler)
router.Use(cors.Middleware(cors.Config{
Origins: "http://localhost:80,http://localhost:8080",
Methods: "GET, PUT, POST, DELETE",
RequestHeaders: "Origin, Authorization, Content-Type, Size",
ExposedHeaders: "",
MaxAge: 50 * time.Second,
Credentials: true,
ValidateHeaders: false,
}))
// configs.ConnectDB() implement db to save differences history
// prometheus.MustRegister(metrics.DiffCounter)
// http.Handle("/metrics", promhttp.Handler())
// http.ListenAndServe(":2000", nil)
router.Run(fmt.Sprintf(":%d", env.Get().Port))
}