mirror of
https://github.com/rancher/norman.git
synced 2025-09-16 15:21:33 +00:00
Add utils methods
This commit is contained in:
@@ -76,6 +76,14 @@ func Capitalize(s string) string {
|
||||
return strings.ToUpper(s[:1]) + s[1:]
|
||||
}
|
||||
|
||||
func Uncapitalize(s string) string {
|
||||
if len(s) <= 1 {
|
||||
return strings.ToLower(s)
|
||||
}
|
||||
|
||||
return strings.ToLower(s[:1]) + s[1:]
|
||||
}
|
||||
|
||||
func LowerTitle(input string) string {
|
||||
runes := []rune(input)
|
||||
for i := 0; i < len(runes); i++ {
|
||||
|
@@ -25,6 +25,10 @@ func (s *Schema) CanList() bool {
|
||||
return slice.ContainsString(s.CollectionMethods, http.MethodGet)
|
||||
}
|
||||
|
||||
func (s *Schema) CanCreate() bool {
|
||||
return slice.ContainsString(s.CollectionMethods, http.MethodPost)
|
||||
}
|
||||
|
||||
func (s *Schema) CanUpdate() bool {
|
||||
return slice.ContainsString(s.ResourceMethods, http.MethodPut)
|
||||
}
|
||||
|
Reference in New Issue
Block a user