mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-01-22 09:58:14 -05:00
27 lines
589 B
Go
27 lines
589 B
Go
package panel
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/go-resty/resty/v2"
|
|
path2 "path"
|
|
)
|
|
|
|
// Debug set the client debug for client
|
|
func (c *Client) Debug() {
|
|
c.client.SetDebug(true)
|
|
}
|
|
|
|
func (c *Client) assembleURL(path string) string {
|
|
return path2.Join(c.APIHost + path)
|
|
}
|
|
func (c *Client) checkResponse(res *resty.Response, path string, err error) error {
|
|
if err != nil {
|
|
return fmt.Errorf("request %s failed: %s", c.assembleURL(path), err)
|
|
}
|
|
if res.StatusCode() >= 400 {
|
|
body := res.Body()
|
|
return fmt.Errorf("request %s failed: %s", c.assembleURL(path), string(body))
|
|
}
|
|
return nil
|
|
}
|