mirror of
https://git.macaw.me/skunky/SkunkyArt.git
synced 2025-04-03 21:17:35 +03:00
Два API-эндпоинта
This commit is contained in:
parent
1464584264
commit
db53a8bd90
10 changed files with 115 additions and 48 deletions
14
app/util.go
14
app/util.go
|
@ -64,6 +64,7 @@ type skunkyart struct {
|
|||
Query, QueryRaw string
|
||||
|
||||
API API
|
||||
Version string
|
||||
|
||||
Templates struct {
|
||||
About struct {
|
||||
|
@ -131,7 +132,7 @@ func UrlBuilder(strs ...string) string {
|
|||
str.WriteString(CFG.URI)
|
||||
for n, x := range strs {
|
||||
str.WriteString(x)
|
||||
if n+1 < l && !(strs[n+1][0] == '?' || strs[n+1][0] == '&') && !(x[0] == '?' || x[0] == '&') {
|
||||
if n := n+1; n < l && len(strs[n]) != 0 && !(strs[n][0] == '?' || strs[n][0] == '&') && !(x[0] == '?' || x[0] == '&') {
|
||||
str.WriteString("/")
|
||||
}
|
||||
}
|
||||
|
@ -153,6 +154,14 @@ func (s skunkyart) ReturnHTTPError(status int) {
|
|||
wr(s.Writer, msg.String())
|
||||
}
|
||||
|
||||
func (s skunkyart) SetFilename(name string) {
|
||||
var filename strings.Builder
|
||||
filename.WriteString(`filename="`)
|
||||
filename.WriteString(name)
|
||||
filename.WriteString(`"`)
|
||||
s.Writer.Header().Add("Content-Disposition", filename.String())
|
||||
}
|
||||
|
||||
type Downloaded struct {
|
||||
Headers http.Header
|
||||
Status int
|
||||
|
@ -189,6 +198,9 @@ func ParseMedia(media devianter.Media, thumb ...int) string {
|
|||
if len(mediaUrl) != 0 && CFG.Proxy {
|
||||
mediaUrl = mediaUrl[21:]
|
||||
dot := strings.Index(mediaUrl, ".")
|
||||
if filename == "" {
|
||||
filename = "image.gif"
|
||||
}
|
||||
return UrlBuilder("media", "file", mediaUrl[:dot], mediaUrl[dot+11:], "&filename=", filename)
|
||||
}
|
||||
return mediaUrl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue