Skip to content

Commit

Permalink
fix response check
Browse files Browse the repository at this point in the history
  • Loading branch information
cl1337 committed Apr 10, 2018
1 parent a920526 commit 66a2576
Show file tree
Hide file tree
Showing 24 changed files with 49 additions and 97 deletions.
8 changes: 3 additions & 5 deletions codegen/template_bundle/template_files.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions codegen/templates/endpoint.tmpl
Expand Up @@ -163,10 +163,8 @@ func (h *{{$handlerName}}) HandleRequest(
zap.String("endpoint", h.endpoint.EndpointName),
}
{{- if ne .ResponseType ""}}
if response != nil {
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
{{- end}}
for _, k := range cliRespHeaders.Keys() {
Expand Down
Expand Up @@ -110,10 +110,8 @@ func (h *BarArgWithHeadersHandler) HandleRequest(
zfields := []zapcore.Field{
zap.String("endpoint", h.endpoint.EndpointName),
}
if response != nil {
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
for _, k := range cliRespHeaders.Keys() {
if val, ok := cliRespHeaders.Get(k); ok {
Expand Down
Expand Up @@ -232,10 +232,8 @@ func (h *BarArgWithManyQueryParamsHandler) HandleRequest(
zfields := []zapcore.Field{
zap.String("endpoint", h.endpoint.EndpointName),
}
if response != nil {
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
for _, k := range cliRespHeaders.Keys() {
if val, ok := cliRespHeaders.Get(k); ok {
Expand Down
Expand Up @@ -176,10 +176,8 @@ func (h *BarArgWithNestedQueryParamsHandler) HandleRequest(
zfields := []zapcore.Field{
zap.String("endpoint", h.endpoint.EndpointName),
}
if response != nil {
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
for _, k := range cliRespHeaders.Keys() {
if val, ok := cliRespHeaders.Get(k); ok {
Expand Down
Expand Up @@ -107,10 +107,8 @@ func (h *BarArgWithParamsHandler) HandleRequest(
zfields := []zapcore.Field{
zap.String("endpoint", h.endpoint.EndpointName),
}
if response != nil {
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
for _, k := range cliRespHeaders.Keys() {
if val, ok := cliRespHeaders.Get(k); ok {
Expand Down
Expand Up @@ -104,10 +104,8 @@ func (h *BarArgWithQueryHeaderHandler) HandleRequest(
zfields := []zapcore.Field{
zap.String("endpoint", h.endpoint.EndpointName),
}
if response != nil {
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
for _, k := range cliRespHeaders.Keys() {
if val, ok := cliRespHeaders.Get(k); ok {
Expand Down
Expand Up @@ -118,10 +118,8 @@ func (h *BarArgWithQueryParamsHandler) HandleRequest(
zfields := []zapcore.Field{
zap.String("endpoint", h.endpoint.EndpointName),
}
if response != nil {
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
for _, k := range cliRespHeaders.Keys() {
if val, ok := cliRespHeaders.Get(k); ok {
Expand Down
6 changes: 2 additions & 4 deletions codegen/test_data/endpoints/bar_bar_method_normal.gogen
Expand Up @@ -110,10 +110,8 @@ func (h *BarNormalHandler) HandleRequest(
zfields := []zapcore.Field{
zap.String("endpoint", h.endpoint.EndpointName),
}
if response != nil {
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
for _, k := range cliRespHeaders.Keys() {
if val, ok := cliRespHeaders.Get(k); ok {
Expand Down
6 changes: 2 additions & 4 deletions codegen/test_data/endpoints/bar_bar_method_toomanyargs.gogen
Expand Up @@ -102,10 +102,8 @@ func (h *BarTooManyArgsHandler) HandleRequest(
zfields := []zapcore.Field{
zap.String("endpoint", h.endpoint.EndpointName),
}
if response != nil {
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
}
for _, k := range cliRespHeaders.Keys() {
if val, ok := cliRespHeaders.Get(k); ok {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 66a2576

Please sign in to comment.