move set header to top (#158)

This commit is contained in:
2021-04-28 02:58:26 +08:00 committed by GitHub
parent ab924fba7d
commit dea02bd1e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -51,13 +51,13 @@ func (s *Server) AddServiceInvocationHandler(route string, fn func(ctx context.C
// write to response if handler returned data // write to response if handler returned data
if o != nil && o.Data != nil { if o != nil && o.Data != nil {
if o.ContentType != "" {
w.Header().Set("Content-type", o.ContentType)
}
if _, err := w.Write(o.Data); err != nil { if _, err := w.Write(o.Data); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
if o.ContentType != "" {
w.Header().Set("Content-type", o.ContentType)
}
} }
}))) })))