eia-api-go/pkg/eia/eia_reflection.go

26 lines
477 B
Go

package eia
import (
"reflect"
"slices"
"strings"
eiaapi "gitea.libretechconsulting.com/50W/eia-api-go/api"
)
func GetRoutes() []string {
eiaClientInterface := new(eiaapi.ClientInterface)
t := reflect.TypeOf(eiaClientInterface).Elem()
routes := make([]string, 0, t.NumMethod())
for i := 0; i < t.NumMethod(); i++ {
method := t.Method(i)
if strings.HasSuffix(method.Name, "Facet") {
routes = append(routes, method.Name)
}
}
return slices.Clip(routes)
}