change error handler behavior and fix error when a model isn't found (#173)

This commit is contained in:
Patrick Devine
2023-07-21 23:02:12 -07:00
committed by GitHub
parent 37324a0a00
commit 6d6b0d3321
4 changed files with 17 additions and 36 deletions

View File

@@ -210,15 +210,9 @@ func (c *Client) List(ctx context.Context) (*ListResponse, error) {
return &lr, nil
}
type DeleteProgressFunc func(ProgressResponse) error
func (c *Client) Delete(ctx context.Context, req *DeleteRequest, fn DeleteProgressFunc) error {
return c.stream(ctx, http.MethodDelete, "/api/delete", req, func(bts []byte) error {
var resp ProgressResponse
if err := json.Unmarshal(bts, &resp); err != nil {
return err
}
return fn(resp)
})
func (c *Client) Delete(ctx context.Context, req *DeleteRequest) error {
if err := c.do(ctx, http.MethodDelete, "/api/delete", req, nil); err != nil {
return err
}
return nil
}