2024-12-22 19:14:29 +04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-12-22 22:44:24 +04:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
2024-12-22 19:14:29 +04:00
|
|
|
)
|
|
|
|
|
2024-12-22 22:44:24 +04:00
|
|
|
func setupRouter() *gin.Engine {
|
|
|
|
// Disable Console Color
|
|
|
|
// gin.DisableConsoleColor()
|
|
|
|
router := gin.Default()
|
|
|
|
|
|
|
|
router.LoadHTMLGlob("templates/*")
|
|
|
|
|
|
|
|
// Ping test
|
|
|
|
router.GET("/ping", func(c *gin.Context) {
|
|
|
|
c.JSON(200, gin.H{
|
|
|
|
"message": "pong",
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
router.GET("/", func(c *gin.Context) {
|
|
|
|
c.HTML(http.StatusOK, "index.html", gin.H{
|
|
|
|
"test": "templating or something",
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
return router
|
|
|
|
}
|
|
|
|
|
2024-12-22 19:14:29 +04:00
|
|
|
func main() {
|
2024-12-22 22:44:24 +04:00
|
|
|
router := setupRouter()
|
|
|
|
// Listen and Server in 0.0.0.0:8080
|
|
|
|
router.Run(":8080")
|
2024-12-22 19:14:29 +04:00
|
|
|
}
|