Minor refactor
This commit is contained in:
16
api.go
16
api.go
@@ -51,13 +51,7 @@ func update(obj storebus.Object, patch storebus.Object) error {
|
|||||||
switch o := obj.(type) {
|
switch o := obj.(type) {
|
||||||
|
|
||||||
case *Template:
|
case *Template:
|
||||||
p := patch.(*Template)
|
return updateTemplate(o, patch.(*Template))
|
||||||
|
|
||||||
if p.Title != "" {
|
|
||||||
o.Title = p.Title
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("Unsupported type: %s", obj.GetType())
|
return fmt.Errorf("Unsupported type: %s", obj.GetType())
|
||||||
@@ -65,6 +59,14 @@ func update(obj storebus.Object, patch storebus.Object) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateTemplate(template *Template, patch *Template) error {
|
||||||
|
if patch.Title != "" {
|
||||||
|
template.Title = patch.Title
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func mayCreate(obj storebus.Object, r *http.Request) error {
|
func mayCreate(obj storebus.Object, r *http.Request) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user