Skip to content

Commit

Permalink
Add default content type if no one specified
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Aug 15, 2017
1 parent 96bc784 commit 9bc9220
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ func (tmpl *Template) Render(templateName string, obj interface{}, request *http
func (tmpl *Template) Execute(templateName string, obj interface{}, req *http.Request, w http.ResponseWriter) error {
result, err := tmpl.Render(templateName, obj, req, w)
if err == nil {
if w.Header().Get("Content-Type") == "" {
w.Header().Set("Content-Type", "text/html")
}

_, err = w.Write([]byte(result))
}
return err
Expand Down

0 comments on commit 9bc9220

Please sign in to comment.