Documentation ¶
Index ¶
- Variables
- func NewRequest(ctx context.Context, method string, url string, headers map[string]string, ...) (*http.Request, error)
- func PackURL(addr string, values url.Values) (string, error)
- func PackURLPath(tpl string, args map[string]string) string
- type DebugLevel
- type Response
- func ClientDo(client *http.Client, req *http.Request, streamResp ...bool) (*Response, error)
- func Delete(ctx context.Context, url string, headers map[string]string, query url.Values) (*Response, error)
- func Do(req *http.Request) (*Response, error)
- func Get(ctx context.Context, url string, headers map[string]string, query url.Values) (*Response, error)
- func Patch(ctx context.Context, url string, headers map[string]string, query url.Values, ...) (*Response, error)
- func Post(ctx context.Context, url string, headers map[string]string, query url.Values, ...) (*Response, error)
- func PostForm(ctx context.Context, url string, form url.Values) (*Response, error)
- func Put(ctx context.Context, url string, headers map[string]string, query url.Values, ...) (*Response, error)
- type RestCli
- func (rest *RestCli) Body(body io.Reader) *RestCli
- func (rest *RestCli) ClearHeader(header string) *RestCli
- func (rest *RestCli) ClearQuery(query string) *RestCli
- func (rest *RestCli) Client(cli *http.Client) *RestCli
- func (rest *RestCli) Context(ctx context.Context) *RestCli
- func (rest *RestCli) Debug(level ...DebugLevel) *RestCli
- func (rest *RestCli) Delete() *RestCli
- func (rest *RestCli) Do() (*Response, error)
- func (rest *RestCli) FormData(data url.Values) *RestCli
- func (rest *RestCli) Get() *RestCli
- func (rest *RestCli) Host(host string) *RestCli
- func (rest *RestCli) Into(status string, resp interface{}) *RestCli
- func (rest *RestCli) Method(method string) *RestCli
- func (rest *RestCli) Object(body interface{}) *RestCli
- func (rest *RestCli) Patch() *RestCli
- func (rest *RestCli) Post() *RestCli
- func (rest *RestCli) Put() *RestCli
- func (rest *RestCli) ResourcePath(resource string) *RestCli
- func (rest *RestCli) SetHeader(header, value string) *RestCli
- func (rest *RestCli) SetQuery(query string, value ...string) *RestCli
- func (rest *RestCli) Stream() *RestCli
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultHTTPClient = func() *http.Client { return &http.Client{ Transport: &http.Transport{ TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, }, }, } }()
DefaultHTTPClient will return a default configured http client
Functions ¶
func NewRequest ¶
func NewRequest(ctx context.Context, method string, url string, headers map[string]string, query url.Values, body io.Reader) (*http.Request, error)
NewRequest will create a http request with the specified data
Types ¶
type DebugLevel ¶
type DebugLevel int
DebugLevel of the debug logs
const ( Debug0 DebugLevel = 0 Debug1 DebugLevel = 1 Debug2 DebugLevel = 2 )
Prededfined debuglog level
type Response ¶
Response is a collection of the response data
func Delete ¶
func Delete(ctx context.Context, url string, headers map[string]string, query url.Values) (*Response, error)
Delete will delete remote resource
func Get ¶
func Get(ctx context.Context, url string, headers map[string]string, query url.Values) (*Response, error)
Get will get remote data with custom headers
func Patch ¶
func Patch(ctx context.Context, url string, headers map[string]string, query url.Values, body io.Reader) (*Response, error)
Patch will partially update a remote resource
func Post ¶
func Post(ctx context.Context, url string, headers map[string]string, query url.Values, body io.Reader) (*Response, error)
Post will create remote resource
type RestCli ¶
type RestCli struct {
// contains filtered or unexported fields
}
RestCli represents a restful http request
func (*RestCli) ClearHeader ¶
ClearHeader will clear a header from the rest request
func (*RestCli) ClearQuery ¶
ClearQuery will clear a query from the rest request
func (*RestCli) Debug ¶
func (rest *RestCli) Debug(level ...DebugLevel) *RestCli
Debug will turn on or turn off the debug process
func (*RestCli) ResourcePath ¶
ResourcePath will set the remote api Resource for the rest request
Click to show internal directories.
Click to hide internal directories.