Refactor HTTP endpoints to be less complicated and follow better standards

This commit is contained in:
Dane Everitt
2020-10-31 10:04:20 -07:00
parent c4703f5541
commit 334b3e8d10
12 changed files with 203 additions and 245 deletions

View File

@@ -13,10 +13,10 @@ import (
// Notifies the panel of a backup's state and returns an error if one is encountered
// while performing this action.
func (s *Server) notifyPanelOfBackup(uuid string, ad *backup.ArchiveDetails, successful bool) error {
r := api.NewRequester()
rerr, err := r.SendBackupStatus(uuid, ad.ToRequest(successful))
if rerr != nil || err != nil {
if err != nil {
r := api.New()
err := r.SendBackupStatus(uuid, ad.ToRequest(successful))
if err != nil {
if !api.IsRequestError(err) {
s.Log().WithFields(log.Fields{
"backup": uuid,
"error": err,
@@ -25,7 +25,7 @@ func (s *Server) notifyPanelOfBackup(uuid string, ad *backup.ArchiveDetails, suc
return err
}
return errors.New(rerr.String())
return errors.New(err.Error())
}
return nil