diff options
| author | Chris Lu <chris.lu@uber.com> | 2021-04-10 23:47:47 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@uber.com> | 2021-04-10 23:47:47 -0700 |
| commit | af313dff58bf82a731dbce72535b72f1979d6740 (patch) | |
| tree | 3799d0cc618c248c6c3bca4bdcc002e62ea92727 /weed/util/http_util.go | |
| parent | 98c08a3dcd3d3a3115828dc04b5f11e56cd67489 (diff) | |
| download | seaweedfs-af313dff58bf82a731dbce72535b72f1979d6740.tar.xz seaweedfs-af313dff58bf82a731dbce72535b72f1979d6740.zip | |
add gateway for easier POST and DELETE blobs
Diffstat (limited to 'weed/util/http_util.go')
| -rw-r--r-- | weed/util/http_util.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/weed/util/http_util.go b/weed/util/http_util.go index 135d10c45..1c1b2b377 100644 --- a/weed/util/http_util.go +++ b/weed/util/http_util.go @@ -124,6 +124,28 @@ func Delete(url string, jwt string) error { return errors.New(string(body)) } +func DeleteProxied(url string, jwt string) (body []byte, httpStatus int, err error) { + req, err := http.NewRequest("DELETE", url, nil) + if jwt != "" { + req.Header.Set("Authorization", "BEARER "+string(jwt)) + } + if err != nil { + return + } + resp, err := client.Do(req) + if err != nil { + return + } + defer resp.Body.Close() + body, err = ioutil.ReadAll(resp.Body) + if err != nil { + return + } + httpStatus = resp.StatusCode + return +} + + func GetBufferStream(url string, values url.Values, allocatedBytes []byte, eachBuffer func([]byte)) error { r, err := client.PostForm(url, values) if err != nil { |
