etag write to file
handle query before db loaded
This commit is contained in:
1 parent
12603bbf6c
commit
eaeb32b421
4 files changed
+39
-7
No files matched your search
@@ -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