34ca7de946
Refactored the router generator. Added the NoBanned and NoSessionMismatch middlewares. Removed some of the implicit returns. Refactored some of the routes and their associated stores. Added more Codebeat exclusions. Added the AddReply method to *Topic. Added the Like method to *Topic. MemberOnly now emits a LoginRequired error rather than a generic NoPermissions error. Made progress with Cosora, this time with the profile system.
26 lines
562 B
Go
26 lines
562 B
Go
package main
|
|
|
|
type RouteSubset struct {
|
|
RouteList []*RouteImpl
|
|
}
|
|
|
|
func (set *RouteSubset) Before(line string, literal ...bool) *RouteSubset {
|
|
var litItem bool
|
|
if len(literal) > 0 {
|
|
litItem = literal[0]
|
|
}
|
|
for _, route := range set.RouteList {
|
|
route.RunBefore = append(route.RunBefore, Runnable{line, litItem})
|
|
}
|
|
return set
|
|
}
|
|
|
|
func (set *RouteSubset) Not(path ...string) *RouteSubset {
|
|
for i, route := range set.RouteList {
|
|
if inStringList(route.Path, path) {
|
|
set.RouteList = append(set.RouteList[:i], set.RouteList[i+1:]...)
|
|
}
|
|
}
|
|
return set
|
|
}
|