I am batman
This commit is contained in:
42
api-gateway/cmd/main.go
Normal file
42
api-gateway/cmd/main.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"go-microservices/api-gateway/internal/handlers"
|
||||
"go-microservices/api-gateway/internal/routes"
|
||||
|
||||
"go-microservices/api-gateway/internal/clients"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Starting API Gateway...")
|
||||
app := fiber.New()
|
||||
|
||||
// Connect to AuthService gRPC
|
||||
authServiceAddr := os.Getenv("AUTH_SERVICE_GRPC")
|
||||
|
||||
conn, err := grpc.Dial(authServiceAddr, grpc.WithInsecure())
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to connect to AuthService: %v", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
authClient := clients.NewAuthClient(conn)
|
||||
authHandler := handlers.NewAuthHandler(authClient)
|
||||
|
||||
routes.RegisterAuthRoutes(app, authHandler, authClient)
|
||||
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
port = "8080"
|
||||
}
|
||||
log.Printf("API Gateway listening on :%s", port)
|
||||
|
||||
log.Fatal(app.Listen(":" + port))
|
||||
}
|
||||
Reference in New Issue
Block a user