mirror of
https://github.com/rancher/steve.git
synced 2025-09-01 07:27:46 +00:00
Add ability to disallow methods per a schema attribute
This commit is contained in:
@@ -127,6 +127,25 @@ func Access(s *types.APISchema) interface{} {
|
||||
return s.Attributes["access"]
|
||||
}
|
||||
|
||||
func AddDisallowMethods(s *types.APISchema, methods ...string) {
|
||||
data, ok := s.Attributes["disallowMethods"].(map[string]bool)
|
||||
if !ok {
|
||||
data = map[string]bool{}
|
||||
s.Attributes["disallowMethods"] = data
|
||||
}
|
||||
for _, method := range methods {
|
||||
data[method] = true
|
||||
}
|
||||
}
|
||||
|
||||
func DisallowMethods(s *types.APISchema) map[string]bool {
|
||||
data, ok := s.Attributes["disallowMethods"].(map[string]bool)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func SetAPIResource(s *types.APISchema, resource v1.APIResource) {
|
||||
SetResource(s, resource.Name)
|
||||
SetVerbs(s, resource.Verbs)
|
||||
|
Reference in New Issue
Block a user