Use the same code paths to render the browser version of emails
This commit is contained in:
parent
1232a7c0ec
commit
42caa77b3e
6 changed files with 41 additions and 11 deletions
|
|
@ -54,7 +54,7 @@ func FileServer(r chi.Router, path string, root http.FileSystem, embeddedFS embe
|
|||
// Try to open from local filesystem for development
|
||||
fileToServe, err = root.Open(requestedPath)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to open file", err, http.StatusNotFound)
|
||||
RespondError(w, "Failed to open file", err, http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ func RenderOrError(w http.ResponseWriter, template *BuiltTemplate, context inter
|
|||
err := template.executeTemplate(buf, context)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Strs("files", template.files).Msg("Failed to render template")
|
||||
respondError(w, "Failed to render template", err, http.StatusInternalServerError)
|
||||
RespondError(w, "Failed to render template", err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
buf.WriteTo(w)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func (crw *customResponseWriter) Write(b []byte) (int, error) {
|
|||
}
|
||||
|
||||
// Respond with an error that is visible to the user
|
||||
func respondError(w http.ResponseWriter, m string, e error, s int) {
|
||||
func RespondError(w http.ResponseWriter, m string, e error, s int) {
|
||||
log.Warn().Int("status", s).Err(e).Str("user message", m).Msg("Responding with an error")
|
||||
http.Error(w, m, s)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue