teafolio/page_imageredir.go

29 lines
555 B
Go
Raw Permalink Normal View History

2022-12-31 00:47:07 +00:00
package main
import (
"net/http"
)
func (this *Application) Bannerpage(w http.ResponseWriter, r *http.Request, repoName string) {
this.reposMut.RLock()
defer this.reposMut.RUnlock()
ridx, ok := this.reposAlphabeticalOrder[repoName]
if !ok {
w.Header().Set(`Location`, `/static/no_image.png`)
w.WriteHeader(301)
2022-12-31 00:47:07 +00:00
return
}
images := this.reposCache[ridx].Images
2022-12-31 00:47:07 +00:00
if len(images) == 0 {
w.Header().Set(`Location`, `/static/no_image.png`)
w.WriteHeader(301)
return
}
w.Header().Set(`Location`, images[0].RawURL)
w.WriteHeader(301)
}