diff --git a/main.go b/main.go index 8c8cb3e..a1b2a46 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "net/http" "github.com/gin-gonic/gin" + "jottyfan.de/learngin/modules" ) type EchoRequest struct { @@ -14,9 +15,7 @@ func main() { r := gin.Default() r.LoadHTMLGlob("templates/*") - r.GET("/ping", func(c *gin.Context) { - c.JSON(http.StatusOK, gin.H{"message": "pong"}) - }) + r.GET("/ping", modules.Ping) r.GET("/", func(c *gin.Context) { c.HTML(http.StatusOK, "index.html", nil) diff --git a/modules/ping.go b/modules/ping.go new file mode 100644 index 0000000..e9adaf5 --- /dev/null +++ b/modules/ping.go @@ -0,0 +1,11 @@ +package modules + +import ( + "net/http" + + "github.com/gin-gonic/gin" +) + +func Ping(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{"message": "pong"}) +}