package server import ( "net/http" "git.bronku.xyz/bronku/cake-order-tracker/logging" ) func (h *Server) render(fetch fetcher) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { component, code, err := fetch(r) if err != nil { logging.ErrorPage(err, code).ServeHTTP(w, r) return } w.Header().Set("content-type", "text/html") err = component.Render(r.Context(), w) if err != nil { logging.ErrorPage(err, http.StatusInternalServerError).ServeHTTP(w, r) return } } }