-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
51 lines (42 loc) · 1.05 KB
/
main.go
File metadata and controls
51 lines (42 loc) · 1.05 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
package main
import (
"MicroGo/configs"
"MicroGo/routes"
"github.com/gin-gonic/gin"
nrgin "github.com/newrelic/go-agent/v3/integrations/nrgin"
"github.com/newrelic/go-agent/v3/newrelic"
)
func main() {
app, err := newrelic.NewApplication(
newrelic.ConfigAppName("MicroGo"),
newrelic.ConfigLicense("eu01xx94bbd13030341078e873dba86dFFFFNRAL"),
newrelic.ConfigAppLogForwardingEnabled(true),
)
if err != nil {
panic(err)
}
router := gin.Default()
router.Use(nrgin.Middleware(app))
router.SetTrustedProxies([]string{"127.0.0.1"})
configs.EnvMongoURI()
configs.EnvSecretKey()
configs.ConnectDB()
gin.SetMode(gin.ReleaseMode)
router.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{
"status": "active",
"author": "https://github.com/Fillonit",
"github": "https://github.com/Fillonit/MicroGo",
})
})
routes.UserRoute(router)
routes.PostRoute(router)
routes.ProductRoute(router)
router.NoRoute(func(c *gin.Context) {
c.JSON(404, gin.H{
"status": "404",
"message": "Page not found",
})
})
router.Run("0.0.0.0:8080")
}