pathSections returns the sections of the file of the pkg package that contains the request path constructors for the given service.
(svc *expr.HTTPServiceExpr, pkg string, services *ServicesData)
| 37 | // pathSections returns the sections of the file of the pkg package that |
| 38 | // contains the request path constructors for the given service. |
| 39 | func pathSections(svc *expr.HTTPServiceExpr, pkg string, services *ServicesData) []*codegen.SectionTemplate { |
| 40 | title := fmt.Sprintf("HTTP request path constructors for the %s service.", svc.Name()) |
| 41 | sections := make([]*codegen.SectionTemplate, 0, 1+len(svc.HTTPEndpoints)) |
| 42 | sections = append(sections, |
| 43 | codegen.Header(title, pkg, []*codegen.ImportSpec{ |
| 44 | {Path: "fmt"}, |
| 45 | {Path: "net/url"}, |
| 46 | {Path: "strconv"}, |
| 47 | {Path: "strings"}, |
| 48 | }), |
| 49 | ) |
| 50 | sdata := services.Get(svc.Name()) |
| 51 | for _, e := range svc.HTTPEndpoints { |
| 52 | sections = append(sections, &codegen.SectionTemplate{ |
| 53 | Name: "path", |
| 54 | Source: httpTemplates.Read(pathT), |
| 55 | Data: sdata.Endpoint(e.Name()), |
| 56 | }) |
| 57 | } |
| 58 | |
| 59 | return sections |
| 60 | } |
no test coverage detected