33 lines
878 B
Go

package main
import (
"log"
"net/http"
"hyapp-luck-gateway/internal/config"
"hyapp-luck-gateway/internal/integration/luckygiftclient"
"hyapp-luck-gateway/internal/modules/luckygift"
"hyapp-luck-gateway/internal/router"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
func main() {
cfg := config.Default()
conn, err := grpc.NewClient(cfg.LuckyGiftGRPCAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatalf("create lucky gift grpc client: %v", err)
}
defer conn.Close()
luckyGiftClient := luckygiftclient.NewGRPC(conn)
handler := router.New(cfg, router.Handlers{
LuckyGift: luckygift.New(luckyGiftClient, cfg.RequestTimeout, cfg.AllowedApps),
})
log.Printf("luck-gateway listening on %s", cfg.HTTPAddr)
if err := http.ListenAndServe(cfg.HTTPAddr, handler); err != nil {
log.Fatal(err)
}
}