-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
31 lines (25 loc) · 690 Bytes
/
main.go
File metadata and controls
31 lines (25 loc) · 690 Bytes
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
package main
import (
"log"
"net/http"
"product-management/pkg/api"
"product-management/pkg/cache"
"product-management/pkg/database"
"product-management/pkg/logger"
"product-management/pkg/queue"
"github.com/gorilla/mux"
)
func main() {
// Initialize components
database.InitDB()
queue.InitQueue()
cache.InitCache()
logger.InitLogger()
// API Routes
r := mux.NewRouter()
r.HandleFunc("/products", api.CreateProductHandler).Methods("POST")
r.HandleFunc("/products", api.GetAllProductsHandler).Methods("GET")
r.HandleFunc("/products/{id}", api.GetProductHandler).Methods("GET")
log.Println("Starting server on :8080...")
log.Fatal(http.ListenAndServe(":8080", r))
}