forked from vieter-v/vieter
chore: some final revisions before pr merge
This commit is contained in:
parent
af4c9e1d00
commit
fe3e6e2bab
3 changed files with 21 additions and 24 deletions
|
|
@ -57,12 +57,7 @@ fn (c &Client) send_request<T>(method Method, url string, params map[string]stri
|
|||
// output as a Response<T> object.
|
||||
fn (c &Client) send_request_with_body<T>(method Method, url string, params map[string]string, body string) !Response<T> {
|
||||
res := c.send_request_raw(method, url, params, body)!
|
||||
status := http.status_from_int(res.status_code)
|
||||
|
||||
// Just return an empty successful response
|
||||
if status.is_success() && res.body == '' {
|
||||
return new_data_response(T{})
|
||||
}
|
||||
status := res.status()
|
||||
|
||||
// Non-successful requests are expected to return either an empty body or
|
||||
// Response<string>
|
||||
|
|
@ -77,6 +72,11 @@ fn (c &Client) send_request_with_body<T>(method Method, url string, params map[s
|
|||
return error('Status $res.status_code ($status.str()): $data.message')
|
||||
}
|
||||
|
||||
// Just return an empty successful response
|
||||
if res.body == '' {
|
||||
return new_data_response(T{})
|
||||
}
|
||||
|
||||
data := json.decode(Response<T>, res.body)!
|
||||
|
||||
return data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue