package main
import (
"github.com/gin-gonic/gin"
"net/http"
)
func main() {
router := gin.Default()
router.Any("/", func(ctx *gin.Context) {
switch ctx.Request.Method {
case http.MethodGet:
ctx.JSON(http.StatusOK, gin.H{"Method": http.MethodGet})
case http.MethodPost:
ctx.JSON(http.StatusOK, gin.H{"Method": http.MethodPost})
case http.MethodPut:
ctx.JSON(http.StatusOK, gin.H{"Method": http.MethodPut})
case http.MethodDelete:
ctx.JSON(http.StatusOK, gin.H{"Method": http.MethodDelete})
}
})
err := router.Run(":8080")
if err != nil {
panic(err)
}
}