Simple golang gin ping pong web server.
This commit is contained in:
parent
14a383a55f
commit
0643bb9ce9
3 changed files with 143 additions and 0 deletions
20
2024/10/golang_matrix_demo1/main.go
Normal file
20
2024/10/golang_matrix_demo1/main.go
Normal 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())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue