github.com/Azareal/Gosora@v0.0.0-20210729070923-553e66b59003/router_gen/route_subset.go (about)

     1  package main
     2  
     3  type RouteSubset struct {
     4  	RouteList []*RouteImpl
     5  }
     6  
     7  func (set *RouteSubset) Before(lines ...string) *RouteSubset {
     8  	for _, line := range lines {
     9  		for _, r := range set.RouteList {
    10  			r.RunBefore = append(r.RunBefore, Runnable{line, false})
    11  		}
    12  	}
    13  	return set
    14  }
    15  
    16  func (set *RouteSubset) LitBefore(lines ...string) *RouteSubset {
    17  	for _, line := range lines {
    18  		for _, r := range set.RouteList {
    19  			r.RunBefore = append(r.RunBefore, Runnable{line, true})
    20  		}
    21  	}
    22  	return set
    23  }
    24  
    25  func (set *RouteSubset) Not(path ...string) *RouteSubset {
    26  	for i, route := range set.RouteList {
    27  		if inStringList(route.Path, path) {
    28  			set.RouteList = append(set.RouteList[:i], set.RouteList[i+1:]...)
    29  		}
    30  	}
    31  	return set
    32  }