diff --git a/extractor/utils.go b/extractor/utils.go index 575c274..cee169d 100644 --- a/extractor/utils.go +++ b/extractor/utils.go @@ -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 } diff --git a/routes/users/users.go b/routes/users/users.go index ea28f01..d416756 100644 --- a/routes/users/users.go +++ b/routes/users/users.go @@ -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)) }) }