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

Function payloadBuilders

http/codegen/client_cli.go:170–195  ·  view source on GitHub ↗

payloadBuilders returns the file that contains the payload constructors that use flag values as arguments.

(genpkg string, svc *expr.HTTPServiceExpr, data *cli.CommandData, services *ServicesData)

Source from the content-addressed store, hash-verified

168// payloadBuilders returns the file that contains the payload constructors that
169// use flag values as arguments.
170func payloadBuilders(genpkg string, svc *expr.HTTPServiceExpr, data *cli.CommandData, services *ServicesData) *codegen.File {
171 sd := services.Get(svc.Name())
172 path := filepath.Join(codegen.Gendir, "http", sd.Service.PathName, "client", "cli.go")
173 title := fmt.Sprintf("%s HTTP client CLI support package", svc.Name())
174 specs := []*codegen.ImportSpec{
175 {Path: "encoding/json"},
176 {Path: "fmt"},
177 {Path: "net/http"},
178 {Path: "os"},
179 {Path: "strconv"},
180 {Path: "unicode/utf8"},
181 codegen.GoaImport(""),
182 codegen.GoaNamedImport("http", "goahttp"),
183 {Path: genpkg + "/" + sd.Service.PathName, Name: sd.Service.PkgName},
184 }
185 sections := []*codegen.SectionTemplate{
186 codegen.Header(title, "client", specs),
187 }
188 for _, sub := range data.Subcommands {
189 if sub.BuildFunction != nil {
190 sections = append(sections, cli.PayloadBuilderSection(sub.BuildFunction))
191 }
192 }
193
194 return &codegen.File{Path: path, SectionTemplates: sections}
195}
196
197// buildFlags builds the flag data and build function for an endpoint.
198func buildFlags(svc *ServiceData, e *EndpointData) ([]*cli.FlagData, *cli.BuildFunctionData) {

Callers 1

ClientCLIFilesFunction · 0.70

Calls 6

GoaImportFunction · 0.92
GoaNamedImportFunction · 0.92
HeaderFunction · 0.92
PayloadBuilderSectionFunction · 0.92
NameMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected