-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (34 loc) · 822 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
package main
import (
"fmt"
"log"
"net/http"
"github.com/Atoo35/basic-crud/auth"
"github.com/Atoo35/basic-crud/books"
"github.com/Atoo35/basic-crud/configurations"
"github.com/Atoo35/basic-crud/utils"
"github.com/gin-gonic/gin"
)
var (
config configurations.Config
)
func init() {
var err error
config, err = configurations.LoadConfig(".")
if err != nil {
log.Fatal(err)
}
configurations.Connect(&config)
utils.SetSecretKey([]byte(config.JWT_SECRET))
}
func main() {
router := gin.Default()
books.RegisterRoutes(router, configurations.DB)
auth.RegisterRoutes(router, configurations.DB)
router.GET("/", func(ctx *gin.Context) {
ctx.JSON(http.StatusOK, gin.H{
"message": "Hello World!",
})
})
log.Fatal(router.Run(fmt.Sprintf(":%d", config.PORT)))
}