Initial commit
This commit is contained in:
33
pkg/router/route.go
Normal file
33
pkg/router/route.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package router
|
||||
|
||||
type Route struct {
|
||||
handler func(*Context)
|
||||
method string
|
||||
anonymous bool
|
||||
scope string
|
||||
params map[string]any
|
||||
path string
|
||||
bindModel any
|
||||
}
|
||||
|
||||
func (r Route) Anonymous() Route {
|
||||
for i, route := range routeMap[r.method] {
|
||||
if route.path == r.path {
|
||||
routeMap[r.method][i].scope = ""
|
||||
routeMap[r.method][i].anonymous = true
|
||||
}
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (r Route) RequireScope(scope string) Route {
|
||||
for i, route := range routeMap[r.method] {
|
||||
if route.path == r.path {
|
||||
routeMap[r.method][i].scope = scope
|
||||
routeMap[r.method][i].anonymous = false
|
||||
}
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user