Пример #1
0
// Configure initializes this filter with values from a plugin config.
func (filter *JSON) Configure(conf core.PluginConfig) error {
	rejectValues := conf.GetStringMap("FilterReject", make(map[string]string))
	acceptValues := conf.GetStringMap("FilterAccept", make(map[string]string))

	// Compile regexp from map[string]string to map[string]*regexp.Regexp
	filter.rejectValues = make(map[string]*regexp.Regexp)
	filter.acceptValues = make(map[string]*regexp.Regexp)

	for key, val := range rejectValues {
		exp, err := regexp.Compile(val)
		if err != nil {
			return err
		}
		filter.rejectValues[key] = exp
	}

	for key, val := range acceptValues {
		exp, err := regexp.Compile(val)
		if err != nil {
			return err
		}
		filter.acceptValues[key] = exp
	}

	return nil
}