Documentation
¶
Index ¶
Constants ¶
View Source
const DefaultTimeout = 30
Default request timeout
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HttpRequest ¶
type HttpRequest struct {
//Host service label. For messages
Label string
//Default Http client
Client *http.Client
//Service host
Host string
//Http method. GET, POST, PUT etc
Method string
//Remote endpoint
Url string
//Http headers
Headers http.Header
//Http body
Body []byte
//Count of retry attempts
RetryCount uint
//Retry timeout. Default 30s
RetryTimeout time.Duration
//Retry strategy callback
RetryStrategy func(response *http.Response) bool
//Response error
ResponseErrorStrategy func(response *http.Response, url string, service string) error
//Logger. Implements RequestLogger
Logger Logger
//How many body bytes must be logged
//0 - all body will be logged
LogBodySize int
}
Each request performs via struct bellow
func (HttpRequest) EnsureJSON ¶
func (r HttpRequest) EnsureJSON(method string, url string, header http.Header, body interface{}, dto interface{}) (*http.Response, error)
Ensure JSON request
Click to show internal directories.
Click to hide internal directories.