2023-05-22 09:28:31 -05:00
|
|
|
package extractor
|
|
|
|
|
|
|
|
import (
|
|
|
|
b64 "encoding/base64"
|
2023-11-26 15:00:26 -05:00
|
|
|
"fmt"
|
2023-05-22 09:28:31 -05:00
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2023-11-26 15:00:26 -05:00
|
|
|
func GenGjsonQuery(i int, query string) string {
|
|
|
|
return fmt.Sprintf("%d%s", i, query)
|
|
|
|
}
|
|
|
|
|
2023-05-22 09:28:31 -05:00
|
|
|
func ProxyUrl(url string) string {
|
2023-08-25 18:42:43 -05:00
|
|
|
encodedUrl := b64.URLEncoding.EncodeToString([]byte(url))
|
2023-05-22 09:28:31 -05:00
|
|
|
backendUrl := os.Getenv("URL")
|
|
|
|
|
2023-05-22 17:11:42 -05:00
|
|
|
return backendUrl + "/proxy/img/" + encodedUrl
|
|
|
|
}
|
|
|
|
|
2023-08-21 22:28:23 -05:00
|
|
|
func ProxyClip(url string) string {
|
2023-08-25 18:42:43 -05:00
|
|
|
encodedUrl := b64.URLEncoding.EncodeToString([]byte(url))
|
2023-08-21 22:28:23 -05:00
|
|
|
backendUrl := os.Getenv("URL")
|
|
|
|
|
|
|
|
return backendUrl + "/proxy/clip/" + encodedUrl
|
|
|
|
}
|
|
|
|
|
2023-05-22 17:11:42 -05:00
|
|
|
type ServerFormat struct {
|
|
|
|
Status string `json:"status"`
|
2023-05-29 15:02:10 -05:00
|
|
|
Message interface{} `json:"data"`
|
2023-05-22 17:11:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2023-05-22 09:28:31 -05:00
|
|
|
}
|