ipv6-test-backend/internal/router/routes/ip/myip.go
thehrz b66129d29c
All checks were successful
CI / deploy (push) Successful in 2m27s
pref: update myip API
2024-08-18 23:23:18 +08:00

21 lines
370 B
Go

package ip
import (
"github.com/gin-gonic/gin"
"ipv6-test-node/internal/pkg/response"
"ipv6-test-node/internal/pkg/utils"
"net/http"
"strconv"
)
func MyIP(c *gin.Context) {
version, err := utils.GetIPVersion(c.ClientIP())
if err != nil {
return
}
c.JSON(http.StatusOK, response.MyIPResponse{
Address: c.ClientIP(),
Version: strconv.Itoa(version),
})
}