-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (38 loc) · 911 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 (
"github.com/gin-gonic/gin"
"github.com/meshachdamilare/banking-api/database"
"github.com/meshachdamilare/banking-api/error"
"github.com/meshachdamilare/banking-api/route"
"log"
"net/http"
"time"
)
func main() {
err := database.MigratePostgres()
if err != nil {
panic(err)
}
err = database.MigrateImmuDB()
if err != nil {
log.Println(err)
}
gin.SetMode(gin.ReleaseMode)
router := gin.Default()
router.NoRoute(func(c *gin.Context) {
c.JSON(http.StatusNotFound, error.EndpointNotFound)
})
router.NoMethod(func(c *gin.Context) {
c.JSON(http.StatusForbidden, error.MethodNotAllowed)
})
router.GET("/api/v1", root)
route.BankRoute(router)
log.Println("API running on http://localhost:8002")
log.Fatal(router.Run(":8080"))
}
func root(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "Banking API is working.",
"timestamp": time.Now(),
})
}