From c93093d6c2afd5e3fa2eb1b5b287398311e000fd Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Fri, 14 Jun 2019 11:33:01 +0300 Subject: [PATCH] hero/mvc: func result -> struct, map, slices check if content type is already given by other output value before setting it, look the previous commit for more [2] Former-commit-id: 3e86857d5a7141f6609ad09a46349cfea3e33a89 --- hero/func_result.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hero/func_result.go b/hero/func_result.go index 30cc005a..97afe290 100644 --- a/hero/func_result.go +++ b/hero/func_result.go @@ -334,15 +334,18 @@ func DispatchFuncResult(ctx context.Context, errorHandler ErrorHandler, values [ if custom == nil { // if it's a pointer to struct/map. - if di.IsNil(v) && contentType == "" { + if di.IsNil(v) { // if just a ptr to struct with no content type given // then try to get the previous response writer's content type, // and if that is empty too then force-it to application/json // as the default content type we use for structs/maps. - contentType = ctx.GetContentType() if contentType == "" { - contentType = context.ContentJSONHeaderValue + contentType = ctx.GetContentType() + if contentType == "" { + contentType = context.ContentJSONHeaderValue + } } + continue }