mirror of
https://codeberg.org/SafeTwitch/safetwitch-backend.git
synced 2024-12-22 13:13:00 -05:00
46 lines
849 B
Go
46 lines
849 B
Go
package extractor
|
|
|
|
import (
|
|
b64 "encoding/base64"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func GenGjsonQuery(i int, query string) string {
|
|
return fmt.Sprintf("%d%s", i, query)
|
|
}
|
|
|
|
func ProxyUrl(url string) string {
|
|
encodedUrl := b64.URLEncoding.EncodeToString([]byte(url))
|
|
backendUrl := os.Getenv("URL")
|
|
|
|
return backendUrl + "/proxy/img/" + encodedUrl
|
|
}
|
|
|
|
func ProxyClip(url string) string {
|
|
encodedUrl := b64.URLEncoding.EncodeToString([]byte(url))
|
|
backendUrl := os.Getenv("URL")
|
|
|
|
return backendUrl + "/proxy/clip/" + 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
|
|
}
|