func main()

in example/gin-example/main.go [63:106]


func main() {
	// Load configuration
	config, err := loadConfiguration()
	if err != nil {
		log.Fatalf("Error loading configuration: %s", err)
	}

	if config.App.DebugMode {
		// Set Gin to debug mode
		gin.SetMode(gin.DebugMode)
		log.Println("Running in DEBUG mode")
	} else {
		// Set Gin to release mode for production
		gin.SetMode(gin.ReleaseMode)
		log.Println("Running in RELEASE mode")
	}

	// Initialize Gin router
	r := gin.Default()

	// Load HTML templates
	r.LoadHTMLGlob("templates/*")

	// Define a route for the homepage
	r.GET("/", func(c *gin.Context) {
		c.HTML(200, "index.html", gin.H{
			"Title":   "Home",
			"Message": config.Message,
			"App":     config.App.Name,
		})
	})

	// Define a route for the About page
	r.GET("/about", func(c *gin.Context) {
		c.HTML(200, "about.html", gin.H{
			"Title": "About",
		})
	})

	// Start the server
	if err := r.Run(":8080"); err != nil {
		log.Fatalf("Error starting server: %s", err)
	}
}