etag write to file
handle query before db loaded
This commit is contained in:
@@ -9,6 +9,12 @@ import (
|
||||
|
||||
func HandleJson(c *gin.Context) {
|
||||
ip := c.ClientIP()
|
||||
if !data.Ins().IsLoaded() {
|
||||
log.Error().Msg("DB is not loaded")
|
||||
c.String(http.StatusInternalServerError, "Try again later")
|
||||
return
|
||||
}
|
||||
|
||||
ipData, _, err := data.Ins().Query(ip)
|
||||
if err != nil {
|
||||
log.Err(err).Msg("Failed to query IP")
|
||||
@@ -17,6 +23,8 @@ func HandleJson(c *gin.Context) {
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
ipData["ip"] = ip
|
||||
c.JSON(http.StatusOK, ipData)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user