Skip to content
This repository was archived by the owner on Sep 29, 2020. It is now read-only.

Commit 726f43e

Browse files
authored
Merge pull request #321 from joyent/perigrin/fix-hardware-vendor-create
remove body for POST to hardware vendor
2 parents 35aed33 + 0fae074 commit 726f43e

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

pkg/conch/hardware.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"fmt"
1212
"net/url"
1313
"reflect"
14+
"strings"
1415

1516
"github.com/joyent/conch-shell/pkg/conch/uuid"
1617
)
@@ -132,13 +133,9 @@ func (c *Conch) SaveHardwareVendor(v *HardwareVendor) error {
132133
return ErrBadInput
133134
}
134135

135-
out := struct {
136-
Name string `json:"name"`
137-
}{v.Name}
138-
139-
return c.post(
136+
return c.postString(
140137
"/hardware_vendor/"+url.PathEscape(v.Name),
141-
out,
138+
strings.NewReader(""),
142139
&v,
143140
)
144141
}

pkg/conch/sling.go

+15
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,21 @@ func (c *Conch) post(url string, payload interface{}, response interface{}) erro
238238
return err
239239
}
240240

241+
func (c *Conch) postString(url string, body io.Reader, response interface{}) error {
242+
req, err := c.sling().New().
243+
Post(url).
244+
Set("Content-Type", "application/json").
245+
Body(body).
246+
Request()
247+
248+
if err != nil {
249+
return err
250+
}
251+
252+
_, err = c.httpDo(req, response)
253+
return err
254+
}
255+
241256
func (c *Conch) postNeedsResponse(
242257
url string,
243258
payload interface{},

0 commit comments

Comments
 (0)