Skip to content

Commit

Permalink
Merge bb8220c into 769795e
Browse files Browse the repository at this point in the history
  • Loading branch information
stweiz committed Oct 14, 2016
2 parents 769795e + bb8220c commit bc78279
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions composition/composition_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ func (agg *CompositionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
mergeContext.AddContent(res)

} else if res.Def.Required {
// 404 Error already become logged in logger.go
if res.Content.HttpStatusCode() != 404 {
logging.Application(r.Header).WithField("fetchResult", res).Errorf("error loading content from: %v", res.Def.URL)
}
res.Def.ErrHandler.Handle(res.Err, res.Content.HttpStatusCode(), w, r)
LogFetchResultLoadingError(res, w, r)
return
} else {
logging.Application(r.Header).WithField("fetchResult", res).Warnf("optional content not loaded: %v", res.Def.URL)
Expand Down Expand Up @@ -114,6 +110,14 @@ func (agg *CompositionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
w.Write(html)
}

func LogFetchResultLoadingError(res *FetchResult, w http.ResponseWriter, r *http.Request) {
// 404 and 502 Error already become logged in logger.go
if res.Content.HttpStatusCode() != 404 && res.Content.HttpStatusCode() != 502 {
logging.Application(r.Header).WithField("fetchResult", res).Errorf("error loading content from: %v", res.Def.URL)
}
res.Def.ErrHandler.Handle(res.Err, res.Content.HttpStatusCode(), w, r)
}

func MetadataForRequest(r *http.Request) map[string]interface{} {
return map[string]interface{}{
"host": getHostFromRequest(r),
Expand Down

0 comments on commit bc78279

Please sign in to comment.