Documentation
¶
Index ¶
- Variables
- func JSON[T any](r *Response) (T, error)
- func XML[T any](r *Response) (T, error)
- type ContentWrapper
- type Response
- func (r *Response) Bytes() []byte
- func (r *Response) Content() *ContentWrapper
- func (r *Response) DecodeJSON(dest any) error
- func (r *Response) DecodeXML(dest any) error
- func (r *Response) GetURL() string
- func (r *Response) IsError() bool
- func (r *Response) IsSuccess() bool
- func (r *Response) Raw() *http.Response
- func (r *Response) Text() string
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnsupportedEncoding = errors.New("unsupported encoding format")
ErrUnsupportedEncoding 表示不支持的编码格式
Functions ¶
Types ¶
type ContentWrapper ¶
type ContentWrapper struct {
// contains filtered or unexported fields
}
ContentWrapper 封装响应体的二进制数据,并提供链式解码功能
type Response ¶
type Response struct {
StatusCode int
Headers http.Header
Cookies []*http.Cookie
Proto string // 协议版本 (HTTP/1.1 或 HTTP/2.0)
// contains filtered or unexported fields
}
Response 表示 HTTP 响应
func NewResponse ¶
NewResponse 初始化 Response 对象并读取响应体
func NewResponseFast ¶
NewResponseFast creates a Response without copying the body. Warning: The response body must not be modified after this call. Use this only when you know the body won't be modified.
func (*Response) DecodeJSON ¶
Click to show internal directories.
Click to hide internal directories.