gosora/router_gen/route_subset.go

33 lines
810 B
Go
Raw Normal View History

package main
type RouteSubset struct {
2022-02-21 03:32:53 +00:00
RouteList []*RouteImpl
}
func (set *RouteSubset) Before(lines ...string) *RouteSubset {
2022-02-21 03:32:53 +00:00
for _, line := range lines {
for _, r := range set.RouteList {
r.RunBefore = append(r.RunBefore, Runnable{line, false})
}
}
return set
}
func (set *RouteSubset) LitBefore(lines ...string) *RouteSubset {
2022-02-21 03:32:53 +00:00
for _, line := range lines {
for _, r := range set.RouteList {
r.RunBefore = append(r.RunBefore, Runnable{line, true})
}
}
return set
}
func (set *RouteSubset) Not(path ...string) *RouteSubset {
2022-02-21 03:32:53 +00:00
for i, route := range set.RouteList {
if inStringList(route.Path, path) {
set.RouteList = append(set.RouteList[:i], set.RouteList[i+1:]...)
}
}
return set
}