Documentation
¶
Index ¶
- type Doer
- type ExtendedRequest
- type JSONResponse
- type Request
- func (req *Request) BasicAuth(user, password string) *Request
- func (req *Request) Body(contentType string, value interface{}) *Request
- func (req *Request) ContentType(contentType string) *Request
- func (req *Request) ExecJSON() (*JSONResponse, error)
- func (req *Request) Extended() *ExtendedRequest
- func (req *Request) Header(key string, value interface{}) *Request
- func (req *Request) JSONBody(value interface{}) *Request
- func (req *Request) Method(method interface{}) *Request
- func (req *Request) Query(key string, value interface{}) *Request
- func (req *Request) Url(url interface{}) *Request
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExtendedRequest ¶
type ExtendedRequest struct {
*Request
}
ExtendedRequest contain more advanced functionality. The purpose is to separate those from the visible methods in Request to make the package easier to use
func (*ExtendedRequest) Clone ¶
func (req *ExtendedRequest) Clone() *Request
Clone clones the *Request to allow concurrent usage of the same base configuration
func (*ExtendedRequest) Do ¶
func (req *ExtendedRequest) Do() (*http.Response, error)
Do execute do the request. Caller must close resp.Body in case of non-nil error
func (*ExtendedRequest) NewRequest ¶
func (req *ExtendedRequest) NewRequest() (*http.Request, error)
NewRequest builds a *http.Request
type JSONResponse ¶
type JSONResponse struct {
// contains filtered or unexported fields
}
JSONResponse is holding the JSON specific response
func (*JSONResponse) Get ¶
func (r *JSONResponse) Get(keys ...string) string
Get string from JSON body
func (*JSONResponse) GetArray ¶
func (r *JSONResponse) GetArray(keys ...string) []*fastjson.Value
GetArray gets array from JSON body
func (*JSONResponse) GetInt ¶
func (r *JSONResponse) GetInt(keys ...string) int
GetInt gets int from JSON body
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request hold the request builder data
func NewPost ¶
func NewPost(url interface{}) *Request
NewPost prepares a new *Request with method=POST
func (*Request) ContentType ¶
ContentType is a helper to set content type
func (*Request) ExecJSON ¶
func (req *Request) ExecJSON() (*JSONResponse, error)
ExecJSON executes the request and return a *JSONResponse
func (*Request) Extended ¶
func (req *Request) Extended() *ExtendedRequest
Extended returns the *ExtendedRequest
func (*Request) JSONBody ¶
JSONBody set content-type and provide a jit marshaler to construct the body when the request is prepared