add gateway for easier POST and DELETE blobs

This commit is contained in:
Chris Lu
2021-04-10 23:47:47 -07:00
parent 98c08a3dcd
commit af313dff58
4 changed files with 222 additions and 0 deletions

View File

@@ -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 {