26 lines
495 B
Go
26 lines
495 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
func (this *Application) Bannerpage(w http.ResponseWriter, r *http.Request, repoName string) {
|
|
ctx := r.Context()
|
|
|
|
images, err := this.gitea.ImageFilesForRepo(ctx, repoName)
|
|
if err != nil {
|
|
this.internalError(w, r, fmt.Errorf("listing images: %w", err))
|
|
return
|
|
}
|
|
|
|
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)
|
|
}
|