repo: on any failure to build repo page, redirect to gitea page
This commit is contained in:
parent
bd04f5c117
commit
eda45221cd
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
@ -16,7 +17,8 @@ func (this *Application) Repopage(w http.ResponseWriter, r *http.Request, repoNa
|
|||||||
|
|
||||||
readme, err := this.gitea.RepoFile(ctx, repoName, `README.md`)
|
readme, err := this.gitea.RepoFile(ctx, repoName, `README.md`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.internalError(w, r, fmt.Errorf("loading README.md: %w", err))
|
log.Printf("%s %s: %s", r.Method, r.URL.Path, err)
|
||||||
|
http.Redirect(w, r, repoURL, http.StatusTemporaryRedirect)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +57,8 @@ func (this *Application) Repopage(w http.ResponseWriter, r *http.Request, repoNa
|
|||||||
|
|
||||||
readmeHtml, err := this.gitea.RenderMarkdown(ctx, repoName, strings.Join(lines, "\n"))
|
readmeHtml, err := this.gitea.RenderMarkdown(ctx, repoName, strings.Join(lines, "\n"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.internalError(w, r, fmt.Errorf("rendering markdown: %w", err))
|
log.Printf("%s %s: %s", r.Method, r.URL.Path, fmt.Errorf("rendering markdown: %w", err))
|
||||||
|
http.Redirect(w, r, repoURL, http.StatusTemporaryRedirect)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +66,8 @@ func (this *Application) Repopage(w http.ResponseWriter, r *http.Request, repoNa
|
|||||||
|
|
||||||
images, err := this.gitea.ImageFilesForRepo(ctx, repoName)
|
images, err := this.gitea.ImageFilesForRepo(ctx, repoName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.internalError(w, r, fmt.Errorf("listing images: %w", err))
|
log.Printf("%s %s: %s", r.Method, r.URL.Path, fmt.Errorf("listing images: %w", err))
|
||||||
|
http.Redirect(w, r, repoURL, http.StatusTemporaryRedirect)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user