mirror of
https://codeberg.org/SafeTwitch/safetwitch-backend.git
synced 2025-01-03 03:10:05 -05:00
Add global message format
This commit is contained in:
parent
2bb911111c
commit
129d731a95
2 changed files with 25 additions and 3 deletions
|
@ -9,5 +9,26 @@ func ProxyUrl(url string) string {
|
|||
encodedUrl := b64.StdEncoding.EncodeToString([]byte(url))
|
||||
backendUrl := os.Getenv("URL")
|
||||
|
||||
return backendUrl + "/img/" + encodedUrl
|
||||
return backendUrl + "/proxy/img/" + encodedUrl
|
||||
}
|
||||
|
||||
type ServerFormat struct {
|
||||
Status string `json:"status"`
|
||||
Message interface{} `json:"message"`
|
||||
}
|
||||
|
||||
func FormatMessage(data interface{}, ok bool) ServerFormat {
|
||||
var status string
|
||||
if ok {
|
||||
status = "ok"
|
||||
} else {
|
||||
status = "error"
|
||||
}
|
||||
|
||||
serverFormat := ServerFormat{
|
||||
Status: status,
|
||||
Message: data,
|
||||
}
|
||||
|
||||
return serverFormat
|
||||
}
|
||||
|
|
|
@ -20,8 +20,9 @@ func Routes(route *gin.Engine) {
|
|||
} else {
|
||||
context.Error(err)
|
||||
}
|
||||
} else {
|
||||
context.JSON(200, data)
|
||||
return
|
||||
}
|
||||
|
||||
context.JSON(200, extractor.FormatMessage(data, true))
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue