feat: 网元直连接口-网元配置对端网管信息

This commit is contained in:
TsMask
2024-03-01 19:02:10 +08:00
parent ec57024cca
commit fb59dfa428
2 changed files with 51 additions and 17 deletions

View File

@@ -72,15 +72,15 @@ func Post(url string, data url.Values, headers map[string]string) ([]byte, error
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, errors.New(resp.Status)
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusOK {
return body, errors.New(resp.Status)
}
return body, nil
}
@@ -110,15 +110,15 @@ func PostJSON(url string, data any, headers map[string]string) ([]byte, error) {
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, errors.New(resp.Status)
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusOK {
return body, errors.New(resp.Status)
}
return body, nil
}
@@ -199,15 +199,15 @@ func PutJSON(url string, data any, headers map[string]string) ([]byte, error) {
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, errors.New(resp.Status)
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusOK {
return body, errors.New(resp.Status)
}
return body, nil
}
@@ -230,14 +230,14 @@ func Delete(url string, headers map[string]string) ([]byte, error) {
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, errors.New(resp.Status)
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusOK {
return body, errors.New(resp.Status)
}
return body, nil
}