fix: resolve jikan api eof and context cancellation errors

- add http transport with connection pooling to prevent stale connections
- check ctx.Done() before each retry attempt to abort early
- pass context to renderer to skip writing on canceled requests
This commit is contained in:
2026-05-02 23:27:25 +02:00
parent 723152f370
commit 56f0951d5e
6 changed files with 48 additions and 18 deletions

View File

@@ -30,7 +30,7 @@ func NewHandler(svc *Service, jikanClient *jikan.Client) *Handler {
func renderNotFoundPage(r *http.Request, w http.ResponseWriter) {
w.WriteHeader(http.StatusNotFound)
if err := templates.GetRenderer().ExecuteTemplate(w, "not_found.gohtml", map[string]any{
if err := templates.GetRenderer().ExecuteTemplate(r.Context(), w, "not_found.gohtml", map[string]any{
"CurrentPath": r.URL.Path,
}); err != nil {
log.Printf("render error: %v", err)
@@ -174,7 +174,7 @@ func (h *Handler) HandleWatchPage(w http.ResponseWriter, r *http.Request) {
}
}
if err := templates.GetRenderer().ExecuteTemplate(w, "watch.gohtml", map[string]any{
if err := templates.GetRenderer().ExecuteTemplate(r.Context(), w, "watch.gohtml", map[string]any{
"Anime": anime,
"Episodes": episodes.Data,
"WatchData": watchData,