diff --git a/gateway/assets/test/main.go b/gateway/assets/test/main.go index c38c72057..8072f0000 100644 --- a/gateway/assets/test/main.go +++ b/gateway/assets/test/main.go @@ -157,11 +157,7 @@ func runTemplate(w http.ResponseWriter, filename string, data interface{}) { http.Error(w, fmt.Sprintf("failed to parse template file: %s", err), http.StatusInternalServerError) return } - err = tpl.Execute(w, data) - if err != nil { - http.Error(w, fmt.Sprintf("failed to execute template: %s", err), http.StatusInternalServerError) - return - } + _ = tpl.Execute(w, data) } func main() { diff --git a/gateway/handler.go b/gateway/handler.go index ab9b46ebd..181236b76 100644 --- a/gateway/handler.go +++ b/gateway/handler.go @@ -912,13 +912,11 @@ func (i *handler) handleSuperfluousNamespace(w http.ResponseWriter, r *http.Requ // - redirects to intendedURL after a short delay w.WriteHeader(http.StatusBadRequest) - if err := redirectTemplate.Execute(w, redirectTemplateData{ + _ = redirectTemplate.Execute(w, redirectTemplateData{ RedirectURL: intendedURL, SuggestedPath: intendedPath.String(), ErrorMsg: fmt.Sprintf("invalid path: %q should be %q", r.URL.Path, intendedPath.String()), - }); err != nil { - i.webError(w, r, fmt.Errorf("failed to redirect when fixing superfluous namespace: %w", err), http.StatusBadRequest) - } + }) return true } diff --git a/gateway/handler_codec.go b/gateway/handler_codec.go index 617eb9396..b6a738367 100644 --- a/gateway/handler_codec.go +++ b/gateway/handler_codec.go @@ -195,20 +195,16 @@ func (i *handler) serveCodecHTML(ctx context.Context, w http.ResponseWriter, r * w.Header().Del("Cache-Control") cidCodec := mc.Code(resolvedPath.RootCid().Prefix().Codec) - if err := assets.DagTemplate.Execute(w, assets.DagTemplateData{ + err = assets.DagTemplate.Execute(w, assets.DagTemplateData{ GlobalData: i.getTemplateGlobalData(r, contentPath), Path: contentPath.String(), CID: resolvedPath.RootCid().String(), CodecName: cidCodec.String(), CodecHex: fmt.Sprintf("0x%x", uint64(cidCodec)), Node: parseNode(blockCid, blockData), - }); err != nil { - err = fmt.Errorf("failed to generate HTML listing for this DAG: try fetching raw block with ?format=raw: %w", err) - i.webError(w, r, err, http.StatusInternalServerError) - return false - } + }) - return true + return err == nil } // parseNode does a best effort attempt to parse this request's block such that diff --git a/gateway/handler_unixfs_dir.go b/gateway/handler_unixfs_dir.go index 678c51aba..366514085 100644 --- a/gateway/handler_unixfs_dir.go +++ b/gateway/handler_unixfs_dir.go @@ -212,7 +212,6 @@ func (i *handler) serveDirectory(ctx context.Context, w http.ResponseWriter, r * rq.logger.Debugw("request processed", "tplDataDNSLink", globalData.DNSLink, "tplDataSize", size, "tplDataBackLink", backLink, "tplDataHash", hash) if err := assets.DirectoryTemplate.Execute(w, tplData); err != nil { - i.webError(w, r, err, http.StatusInternalServerError) return false }