Documentation
¶
Index ¶
- Variables
- type Interface
- type Opt
- type PathParam
- type QueryParam
- type RESTClient
- type Request
- func (r *Request) Body(obj interface{}) *Request
- func (r *Request) Do(ctx context.Context) Result
- func (r *Request) Params(args ...QueryParam) *Request
- func (r *Request) Stream(ctx context.Context) (io.ReadCloser, error)
- func (r *Request) SubPath(subPath string, args ...PathParam) *Request
- func (r *Request) Verb(verb string) *Request
- func (r *Request) WsConn(ctx context.Context) (*websocket.Conn, *http.Response, error)
- type Result
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultCodeField = "code" DefaultDataField = "data" DefaultMessageField = "message" )
Functions ¶
This section is empty.
Types ¶
type Opt ¶
type Opt func(client *RESTClient) error
func WithClient ¶ added in v0.5.0
func WithHeaders ¶
func WithProtocol ¶
func WithRetryDelay ¶
func WithRetryTimes ¶
type QueryParam ¶
type QueryParam struct { Name string Value interface{} }
type RESTClient ¶
type RESTClient struct {
// contains filtered or unexported fields
}
func New ¶
func New(ops ...Opt) (*RESTClient, error)
func (*RESTClient) Get ¶
func (r *RESTClient) Get() *Request
func (*RESTClient) GetHeader ¶ added in v0.4.0
func (r *RESTClient) GetHeader() http.Header
func (*RESTClient) Post ¶
func (r *RESTClient) Post() *Request
func (*RESTClient) SetHeader ¶ added in v0.4.0
func (r *RESTClient) SetHeader(header http.Header)
func (*RESTClient) Verb ¶
func (r *RESTClient) Verb(verb string) *Request
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request allows for building up a request to a server in a chained fashion. Any errors are stored until the end of your call, so you only have to check once.
func NewRequest ¶
func NewRequest(c *RESTClient) *Request
func (*Request) Body ¶
Body makes the request use obj as the body. Optional. If obj is a string, try to read a file of that name. If obj is a []byte, send it directly. default marshal it
func (*Request) Do ¶
Do format and executes the request. Returns a Result object for easy response processing.
Error type: http.Client.Do errors are returned directly.
func (*Request) Params ¶
func (r *Request) Params(args ...QueryParam) *Request
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result contains the result of calling Request.Do().
func (Result) RawResponse ¶
func (Result) StatusCode ¶
StatusCode returns the HTTP status code of the request. (Only valid if no error was returned.)
func (Result) TransformResponse ¶
Click to show internal directories.
Click to hide internal directories.