Documentation ¶
Index ¶
- Variables
- func GetExternalIP() (string, error)
- type BaseAPI
- func (s *BaseAPI) Delete(uri string, params map[string]string, headers map[string]string, ...) (*Response, error)
- func (s *BaseAPI) Get(uri string, params map[string]string, headers map[string]string) (*Response, error)
- func (s *BaseAPI) Post(uri string, params map[string]string, headers map[string]string, ...) (*Response, error)
- func (s *BaseAPI) Put(uri string, params map[string]string, headers map[string]string, ...) (*Response, error)
- func (s *BaseAPI) Request(req *RequestForm) (*Response, error)
- func (s *BaseAPI) RequestWithRetry(r *RequestForm) (*Response, error)
- type RequestForm
- type Response
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBadRequest = errors.New("bad request")
ErrBadRequest for request data error
Functions ¶
Types ¶
type BaseAPI ¶
type BaseAPI struct { Host string // global header will send in each request Headers map[string]string // URLPrefix after host:port URLPrefix string RetryCount int RetrySleepSecond int }
BaseAPI for api client
func (*BaseAPI) Delete ¶
func (s *BaseAPI) Delete(uri string, params map[string]string, headers map[string]string, data interface{}) (*Response, error)
Delete request
func (*BaseAPI) Get ¶
func (s *BaseAPI) Get(uri string, params map[string]string, headers map[string]string) (*Response, error)
Get request
func (*BaseAPI) Post ¶
func (s *BaseAPI) Post(uri string, params map[string]string, headers map[string]string, data interface{}) (*Response, error)
Post request
func (*BaseAPI) Put ¶
func (s *BaseAPI) Put(uri string, params map[string]string, headers map[string]string, data interface{}) (*Response, error)
Put request
func (*BaseAPI) Request ¶
func (s *BaseAPI) Request(req *RequestForm) (*Response, error)
Request send to remote host request form contains: method in [GET POST DELETE PUT] url or uri params = query parameter data = post data headers
func (*BaseAPI) RequestWithRetry ¶
func (s *BaseAPI) RequestWithRetry(r *RequestForm) (*Response, error)
RequestWithRetry do
type RequestForm ¶
type RequestForm struct { URL string `form:"url" json:"url"` URI string `form:"uri" json:"uri"` Method string `form:"method" json:"method"` Params map[string]string `form:"params" json:"params"` Data interface{} `form:"data" json:"data"` Headers map[string]string `form:"headers" json:"headers"` }
RequestForm for package request data
Click to show internal directories.
Click to hide internal directories.