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) {
|
|
|
|
|
2022-12-31 01:28:12 +00:00
|
|
|
this.reposMut.RLock()
|
|
|
|
defer this.reposMut.RUnlock()
|
|
|
|
|
2022-12-31 01:55:15 +00:00
|
|
|
ridx, ok := this.reposCacheByName[repoName]
|
2022-12-31 01:28:12 +00:00
|
|
|
if !ok {
|
|
|
|
w.Header().Set(`Location`, `/static/no_image.png`)
|
|
|
|
w.WriteHeader(301)
|
2022-12-31 00:47:07 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-12-31 01:28:12 +00:00
|
|
|
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)
|
|
|
|
}
|