-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.go
More file actions
63 lines (52 loc) · 1.58 KB
/
main.go
File metadata and controls
63 lines (52 loc) · 1.58 KB
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
59
60
61
62
63
package main
import (
"gin-mongo-api/configs"
"gin-mongo-api/routes" //add this
"os"
"time"
docs "gin-mongo-api/docs"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
)
// @title Museum Geologi Bandung
// @version 1.0
// @description API Batuan, Fosil dan Sumber Daya Geologi
// @host localhost:80
// @BasePath /v1
func main() {
configs.ConnectDB()
router := gin.Default()
docs.SwaggerInfo.BasePath = ""
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
router.Use(cors.New(cors.Config{
AllowOrigins: []string{"*"},
AllowMethods: []string{"*"},
AllowHeaders: []string{"Origin", "Content-Length", "Content-Type", "Authorization"},
ExposeHeaders: []string{"Content-Length"},
AllowCredentials: true,
AllowOriginFunc: func(origin string) bool {
return origin == "http://localhost:80"
},
MaxAge: 12 * time.Hour,
}))
routes.InvertebrataRoute(router) //add this
routes.VertebrataRoute(router) //add this
routes.FosilRoute(router) //add this
routes.BatuanRoute(router) //add this
routes.SumberDayaGeologiRoute(router) //add this
routes.BmnRoute(router) //add this
routes.LokasiTemuanRoute(router) //add this
routes.KoordinatRoute(router) //add this
routes.JenisKoleksiRoute(router) //add this
routes.StorageRoute(router) //add this
router.Run(":" + SetPort())
}
func SetPort() string {
port := os.Getenv("PORT")
if len(port) == 0 {
port = "80"
}
return port
}