-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
35 lines (27 loc) · 794 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
package main
import (
foodDetailsController "food-details-integrator-be/foodDetails/controller"
"food-details-integrator-be/foodDetails/service"
"github.com/gin-gonic/gin"
"github.com/go-redis/redis/v8"
"os"
"time"
)
func main() {
client := redis.NewClient(&redis.Options{
Addr: os.Getenv("REDIS_URL"),
DialTimeout: time.Millisecond * 20,
})
r := gin.Default()
cs := service.NewCacheService(*client)
fds := service.NewFoodDetailsService(cs)
detailsController := foodDetailsController.New(fds)
r.GET("/food/:barcode", detailsController.GetFoodDetails)
r.GET("/food/:barcode/kcal", detailsController.GetKcalForQuantity)
r.GET("/", func(context *gin.Context) {
context.JSON(200, gin.H{
"status": "UP",
})
})
r.Run() // listen and serve on 0.0.0.0:8080
}