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

Function headers

dsl/http.go:1128–1155  ·  view source on GitHub ↗

headers returns the mapped attribute containing the headers for the given expression if it's either the root, a service or an endpoint - nil otherwise.

(exp eval.Expression)

Source from the content-addressed store, hash-verified

1126// headers returns the mapped attribute containing the headers for the given
1127// expression if it's either the root, a service or an endpoint - nil otherwise.
1128func headers(exp eval.Expression) *expr.MappedAttributeExpr {
1129 switch e := exp.(type) {
1130 case *expr.RootExpr:
1131 if e.API.HTTP.Headers == nil {
1132 e.API.HTTP.Headers = expr.NewEmptyMappedAttributeExpr()
1133 }
1134 return e.API.HTTP.Headers
1135 case *expr.HTTPServiceExpr:
1136 if e.Headers == nil {
1137 e.Headers = expr.NewEmptyMappedAttributeExpr()
1138 }
1139 return e.Headers
1140 case *expr.HTTPEndpointExpr:
1141 if e.Headers == nil {
1142 e.Headers = expr.NewEmptyMappedAttributeExpr()
1143 }
1144 return e.Headers
1145 case *expr.HTTPResponseExpr:
1146 if e.Headers == nil {
1147 e.Headers = expr.NewEmptyMappedAttributeExpr()
1148 }
1149 return e.Headers
1150 case *expr.MappedAttributeExpr:
1151 return e
1152 default:
1153 return nil
1154 }
1155}
1156
1157// cookies returns the mapped attribute containing the cookies for the given
1158// expression if it's either the root, a service or an endpoint - nil otherwise.

Callers 2

HeaderFunction · 0.85
HeadersFunction · 0.85

Calls 1

Tested by

no test coverage detected