first commit

This commit is contained in:
thuanle
2024-07-13 23:58:47 +07:00
parent 5a47b94c85
commit 4bb5ee09f0
23 changed files with 650316 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
package api
import (
"github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
"net/http"
"thuanle.me/ip-info/internal/data"
)
func HandleJson(c *gin.Context) {
ip := c.ClientIP()
ipData, _, err := data.Ins().Query(ip)
if err != nil {
log.Err(err).Msg("Failed to query IP")
c.String(http.StatusInternalServerError, "")
return
}
c.JSON(http.StatusOK, ipData)
}