MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / ExportAll

Method ExportAll

module/router/iml.go:71–109  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

69}
70
71func (i *imlRouterModule) ExportAll(ctx context.Context) ([]*router_dto.Export, error) {
72
73 apiList, err := i.apiService.ListInfo(ctx)
74 if err != nil {
75 return nil, err
76 }
77 apiIds := utils.SliceToSlice(apiList, func(a *api.Info) string {
78 return a.UUID
79 })
80 proxyCommits, err := i.apiService.ListLatestCommitProxy(ctx, apiIds...)
81 if err != nil {
82 return nil, err
83 }
84 proxyCommitMap := utils.SliceToMap(proxyCommits, func(c *commit.Commit[api.Proxy]) string {
85 return c.Target
86 })
87
88 return utils.SliceToSlice(apiList, func(a *api.Info) *router_dto.Export {
89 match := make([]router_dto.Match, 0)
90 if a.Match == "" {
91 a.Match = "[]"
92 }
93 json.Unmarshal([]byte(a.Match), &match)
94 info := &router_dto.Export{
95 Id: a.UUID,
96 Name: a.Name,
97 Description: a.Description,
98 Path: a.Path,
99 MatchRules: match,
100 Service: a.Service,
101 Team: a.Team,
102 }
103 if v, ok := proxyCommitMap[a.UUID]; ok {
104 info.Proxy = router_dto.FromServiceProxy(v.Data)
105 }
106
107 return info
108 }), nil
109}
110
111func (i *imlRouterModule) SimpleList(ctx context.Context, serviceId string) ([]*router_dto.SimpleItem, error) {
112

Callers

nothing calls this directly

Calls 2

ListInfoMethod · 0.65
ListLatestCommitProxyMethod · 0.65

Tested by

no test coverage detected