kra-new/internal/modules/surface/surface.go

20 lines
537 B
Go

package surface
import (
"strings"
"kra/internal/routecatalog"
"kra/pkg/module"
)
func APIsForPrefix(prefix string, capacity int) []module.API {
items := make([]module.API, 0, capacity)
for _, descriptor := range routecatalog.Descriptors() {
if descriptor.Public || !strings.HasPrefix(descriptor.Path, prefix) || descriptor.Description == "" {
continue
}
items = append(items, module.API{Path: descriptor.Path, Method: descriptor.Method, Group: descriptor.Group, Description: descriptor.Description})
}
return items
}