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

Function HTTP

dsl/http.go:146–168  ·  view source on GitHub ↗

HTTP defines the HTTP transport specific properties of an API, a service or a single method. The function maps the method payload and result types to HTTP properties such as parameters (via path wildcards or query strings), request or response headers, request or response bodies as well as response

(fns ...func())

Source from the content-addressed store, hash-verified

144// })
145// })
146func HTTP(fns ...func()) {
147 if len(fns) > 1 {
148 eval.TooManyArgError()
149 return
150 }
151 fn := func() {}
152 if len(fns) == 1 {
153 fn = fns[0]
154 }
155 switch actual := eval.Current().(type) {
156 case *expr.APIExpr:
157 eval.Execute(fn, expr.Root)
158 case *expr.ServiceExpr:
159 res := expr.Root.API.HTTP.ServiceFor(actual, expr.Root.API.HTTP)
160 res.DSLFunc = fn
161 case *expr.MethodExpr:
162 res := expr.Root.API.HTTP.ServiceFor(actual.Service, expr.Root.API.HTTP)
163 act := res.EndpointFor(actual)
164 act.DSLFunc = fn
165 default:
166 eval.IncompatibleDSL()
167 }
168}
169
170// Consumes adds a MIME type to the list of MIME types the APIs supports when
171// accepting requests. While the DSL supports any MIME type, the code generator

Calls 6

TooManyArgErrorFunction · 0.92
CurrentFunction · 0.92
ExecuteFunction · 0.92
IncompatibleDSLFunction · 0.92
ServiceForMethod · 0.45
EndpointForMethod · 0.45