MCPcopy Create free account
hub / github.com/goadesign/goa / effectiveClientResponseBody

Function effectiveClientResponseBody

http/codegen/service_data.go:2791–2810  ·  view source on GitHub ↗

effectiveClientResponseBody returns the response body shape used by client code generation. When the design fixes the response to a single view, the returned attribute uses that projected ResultType so type collection, union collection, and client decode/init all agree on one transport body.

(body *expr.AttributeExpr, e *expr.HTTPEndpointExpr, md *service.MethodData)

Source from the content-addressed store, hash-verified

2789// returned attribute uses that projected ResultType so type collection, union
2790// collection, and client decode/init all agree on one transport body.
2791func effectiveClientResponseBody(body *expr.AttributeExpr, e *expr.HTTPEndpointExpr, md *service.MethodData) *expr.AttributeExpr {
2792 if body == nil {
2793 return body
2794 }
2795 view := clientResponseViewName(e, md)
2796 if view == "" {
2797 return body
2798 }
2799 body = expr.DupAtt(body)
2800 rt, ok := body.Type.(*expr.ResultTypeExpr)
2801 if !ok {
2802 return body
2803 }
2804 projected, err := expr.Project(rt, view)
2805 if err != nil {
2806 panic(err) // bug
2807 }
2808 body.Type = projected
2809 return body
2810}
2811
2812// clientResponseViewName returns the response view used by client code
2813// generation when the design fixes the response to a single view. An empty

Callers 2

analyzeMethod · 0.85
buildResponsesMethod · 0.85

Calls 3

DupAttFunction · 0.92
ProjectFunction · 0.92
clientResponseViewNameFunction · 0.85

Tested by

no test coverage detected