Simple golang gin ping pong web server.

This commit is contained in:
Tomasz Półgrabia 2024-10-22 23:31:42 +02:00
parent 14a383a55f
commit 0643bb9ce9
3 changed files with 143 additions and 0 deletions

View file

@ -0,0 +1,20 @@
package main
import (
"github.com/gin-gonic/gin"
"time"
)
func main() {
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
"datetime": time.Now(),
})
})
err := r.Run("localhost:8080")
if err != nil {
panic("Couldn't run the server. It failed with the error: " + err.Error())
}
}