work on rule reqmod resmod codegen for serialization

This commit is contained in:
Kevin Pham
2023-12-03 23:34:46 -06:00
parent a83a95c5a5
commit 7883b32335
10 changed files with 454 additions and 25 deletions

View File

@@ -0,0 +1,32 @@
package ruleset_v2
import (
"net/url"
)
type IRuleset interface {
HasRule(url url.URL) bool
GetRule(url url.URL) (rule Rule, exists bool)
}
type Ruleset struct {
rulesetPath string
rules map[string]Rule
}
func (rs Ruleset) GetRule(url url.URL) (rule Rule, exists bool) {
rule, exists = rs.rules[url.Hostname()]
return rule, exists
}
func (rs Ruleset) HasRule(url url.URL) bool {
_, exists := rs.GetRule(url)
return exists
}
func NewRuleset(path string) (Ruleset, error) {
rs := Ruleset{
rulesetPath: path,
}
return rs, nil
}