-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (29 loc) · 826 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
package main
import (
"log"
"posts_api/config"
"posts_api/controller"
"posts_api/repository"
"posts_api/router"
"posts_api/service"
)
const port = ":8000"
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
config.LoadConfig()
//repo, _ := repository.NewFirebaseRepo()
repo, _ := repository.NewSQLiteRepo(false)
postService := service.NewPostService(repo)
postController := controller.NewPostController(postService)
//rout := router.NewMuxRouter()
//rout := router.NewChiRouter()
//rout := router.NewGinRouter()
rout := router.NewFiberRouter()
rout.Get("/", simplePrt)
rout.Get("/posts", postController.GetPosts)
rout.Post("/posts", postController.AddPost)
log.Println("Server listening on port", port)
if err := rout.ListenAndServe(port); err != nil {
log.Fatalf("err: %s\n", err)
}
}