mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-12 11:15:12 +00:00
check the error
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -71,19 +71,20 @@ func Handler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
defer rsp.Body.Close()
|
||||
|
||||
if rsp.StatusCode != 200 {
|
||||
http.Error(w, "unexpected error", 500)
|
||||
return
|
||||
}
|
||||
|
||||
result := map[string]interface{}{}
|
||||
|
||||
b, err := ioutil.ReadAll(rsp.Body)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
if rsp.StatusCode != 200 {
|
||||
log.Printf("Error calling api: status: %v %v", rsp.StatusCode, string(b))
|
||||
http.Error(w, "unexpected error", 500)
|
||||
return
|
||||
}
|
||||
|
||||
result := map[string]interface{}{}
|
||||
|
||||
if err := json.Unmarshal(b, &result); err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user