-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
45 lines (36 loc) · 1.2 KB
/
main.go
File metadata and controls
45 lines (36 loc) · 1.2 KB
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
40
41
42
43
44
45
package main
import (
"log"
"net/http"
"airline-system/handlers"
"airline-system/repository"
"airline-system/services"
"github.com/gorilla/mux"
)
func main() {
// Initialize repositories
userRepo := repository.NewUserRepository()
flightRepo := repository.NewFlightRepository()
bookingRepo := repository.NewBookingRepository()
paymentRepo := repository.NewPaymentRepository()
// Initialize services
authService := services.NewAuthService(userRepo)
flightService := services.NewFlightService(flightRepo)
bookingService := services.NewBookingService(bookingRepo, flightRepo)
paymentService := services.NewPaymentService(bookingRepo, paymentRepo)
// Initialize handlers
authHandler := handlers.NewAuthHandler(authService)
flightHandler := handlers.NewFlightHandler(flightService)
bookingHandler := handlers.NewBookingHandler(bookingService)
paymentHandler := handlers.NewPaymentHandler(paymentService)
// Setup router
r := mux.NewRouter()
// Register routes
RegisterRoutes(r, authHandler, flightHandler, bookingHandler, paymentHandler)
// Start server
log.Println("Server starting on :8080")
err := http.ListenAndServe(":8080", r)
if err != nil {
log.Fatalf("Server failed: %v", err)
}
}