mirror of
https://github.com/rancher/norman.git
synced 2025-08-16 06:23:36 +00:00
Add utils methods
This commit is contained in:
parent
eec4103473
commit
45662fe756
@ -76,6 +76,14 @@ func Capitalize(s string) string {
|
|||||||
return strings.ToUpper(s[:1]) + s[1:]
|
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 {
|
func LowerTitle(input string) string {
|
||||||
runes := []rune(input)
|
runes := []rune(input)
|
||||||
for i := 0; i < len(runes); i++ {
|
for i := 0; i < len(runes); i++ {
|
||||||
|
@ -25,6 +25,10 @@ func (s *Schema) CanList() bool {
|
|||||||
return slice.ContainsString(s.CollectionMethods, http.MethodGet)
|
return slice.ContainsString(s.CollectionMethods, http.MethodGet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Schema) CanCreate() bool {
|
||||||
|
return slice.ContainsString(s.CollectionMethods, http.MethodPost)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Schema) CanUpdate() bool {
|
func (s *Schema) CanUpdate() bool {
|
||||||
return slice.ContainsString(s.ResourceMethods, http.MethodPut)
|
return slice.ContainsString(s.ResourceMethods, http.MethodPut)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user