0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch-backend.git synced 2024-12-22 13:13:00 -05:00
safetwitch-backend/extractor/utils.go
2023-05-29 16:02:10 -04:00

34 lines
572 B
Go

package extractor
import (
b64 "encoding/base64"
"os"
)
func ProxyUrl(url string) string {
encodedUrl := b64.StdEncoding.EncodeToString([]byte(url))
backendUrl := os.Getenv("URL")
return backendUrl + "/proxy/img/" + encodedUrl
}
type ServerFormat struct {
Status string `json:"status"`
Message interface{} `json:"data"`
}
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
}