Skip to content

Commit

Permalink
Fix for unexpected JSON array responses
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Lo-A-Foe <andy.loafoe@gmail.com>
  • Loading branch information
loafoe committed Sep 23, 2021
1 parent af52e2f commit efd30fe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dicom/config_service_store_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,16 @@ func (c *ConfigService) GetStoreService(options ...OptionFunc) (*SCPConfig, *Res
return nil, nil, err
}
req.Header.Set("Content-Type", "application/json")
var service SCPConfig
var service []SCPConfig // This will change. The API always return a JSON array now
resp, err := c.client.do(req, &service)
if (err != nil && err != io.EOF) || resp == nil {
if resp == nil && err != nil {
err = fmt.Errorf("GetStoreService: %w", ErrEmptyResult)
}
return nil, resp, err
}
return &service, resp, nil
if len(service) == 0 {
return nil, resp, ErrEmptyResult
}
return &service[0], resp, nil
}

0 comments on commit efd30fe

Please sign in to comment.