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

Method filterOptions

controller/strategy/iml.go:102–125  ·  view source on GitHub ↗
(ctx *gin.Context, scope string)

Source from the content-addressed store, hash-verified

100}
101
102func (i *imlStrategyController) filterOptions(ctx *gin.Context, scope string) ([]*strategy_dto.FilterOption, error) {
103 m, has := strategy_filter.Options(scope)
104 if !has {
105 return nil, fmt.Errorf("scope not found: %s", scope)
106 }
107
108 list := utils.MapToSlice(m, func(key string, value *strategy_filter.Option) *strategy_dto.FilterOption {
109 pattern := ""
110 if value.Pattern != nil {
111 pattern = value.Pattern.String()
112 }
113 return &strategy_dto.FilterOption{
114 Name: value.Name,
115 Title: value.Title,
116 Type: value.Type,
117 Pattern: pattern,
118 Options: value.Options,
119 }
120 })
121 sort.Slice(list, func(i, j int) bool {
122 return list[i].Name < list[j].Name
123 })
124 return list, nil
125}
126
127func (i *imlStrategyController) FilterServiceOptions(ctx *gin.Context) ([]*strategy_dto.FilterOption, error) {
128 return i.filterOptions(ctx, strategy_filter.ScopeService)

Callers 2

FilterServiceOptionsMethod · 0.95
FilterGlobalOptionsMethod · 0.95

Calls 2

OptionsMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected