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

Method Finalize

expr/http_error.go:89–120  ·  view source on GitHub ↗

Finalize looks up the corresponding method error expression.

(a *HTTPEndpointExpr)

Source from the content-addressed store, hash-verified

87
88// Finalize looks up the corresponding method error expression.
89func (e *HTTPErrorExpr) Finalize(a *HTTPEndpointExpr) {
90 var ee *ErrorExpr
91 switch p := e.Response.Parent.(type) {
92 case *HTTPEndpointExpr:
93 ee = p.MethodExpr.Error(e.Name)
94 case *HTTPServiceExpr:
95 ee = p.Error(e.Name)
96 case *RootExpr:
97 ee = Root.Error(e.Name)
98 }
99 e.ErrorExpr = ee
100 e.Response.Finalize(a, e.AttributeExpr)
101 if e.Response.Body == nil {
102 e.Response.Body = httpErrorResponseBody(a, e)
103 e.Response.Body.Finalize()
104 }
105 // map any unmapped attributes in ErrorResult type to response headers
106 e.Response.mapUnmappedAttrs(e.AttributeExpr)
107
108 // Initialize response content type if result is media type.
109 if e.Response.Body.Type == Empty {
110 return
111 }
112 if e.Response.ContentType != "" {
113 return
114 }
115 mt, ok := e.Response.Body.Type.(*ResultTypeExpr)
116 if !ok {
117 return
118 }
119 e.Response.ContentType = mt.Identifier
120}
121
122// Dup creates a copy of the error expression.
123func (e *HTTPErrorExpr) Dup() *HTTPErrorExpr {

Callers

nothing calls this directly

Calls 4

httpErrorResponseBodyFunction · 0.85
mapUnmappedAttrsMethod · 0.80
FinalizeMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected