teafolio/page_imageredir.go

29 lines
549 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()
2022-12-31 01:55:15 +00:00
ridx, ok := this.reposCacheByName[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)
}