GoStart/main.go

33 lines
732 B
Go

package main
import (
"GoStart/src/api"
"GoStart/src/routes"
"GoStart/src/utils"
"fmt"
"net/http"
)
func main() {
// Load Configurations
cfg, err := utils.LoadConfig()
if err != nil {
fmt.Printf("Failed to load config: %v\n", err)
return
}
mux := http.NewServeMux()
// Initialize Home View
mux.HandleFunc("/", routes.RootHandler)
// Serve Static Files
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("web/static"))))
// Example view
mux.HandleFunc("/example", routes.ExampleHandler)
// API endpoint
mux.HandleFunc("/api/example", api.ExampleHandler)
fmt.Printf("Server is running on http://localhost:%d\n", cfg.Port)
http.ListenAndServe(fmt.Sprintf(":%d", cfg.Port), mux)
}