Documentation
¶
Index ¶
- Constants
- func BuildCURL(request HttpRequest) string
- func Ensure(request HttpRequest) (*http.Response, []byte, error)
- func ParallelPaginatorJsonEnsure[F any, R any](form F, hr HttpRequest) (items []R, meta gorest.Meta, e porterr.IError)
- func SecureClient(certPath string) (*http.Client, porterr.IError)
- type HttpRequest
- type IPaginator
- type Logger
- type Paginator
- type PaginatorResponse
Constants ¶
View Source
const DefaultTimeout = 30
DefaultTimeout Default request timeout
Variables ¶
This section is empty.
Functions ¶
func ParallelPaginatorJsonEnsure ¶ added in v1.3.0
func ParallelPaginatorJsonEnsure[F any, R any](form F, hr HttpRequest) (items []R, meta gorest.Meta, e porterr.IError)
ParallelPaginatorJsonEnsure Execute api call that can have async count of parallel request
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) error
//Logger. Implements RequestLogger
Logger Logger
//How many body bytes must be logged
//0 - all body will be logged
LogBodySize int
}
HttpRequest 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)
EnsureJSON ensure JSON request
func (*HttpRequest) InitDefaultLogger ¶ added in v1.2.0
func (r *HttpRequest) InitDefaultLogger()
InitDefaultLogger Init default logger
type IPaginator ¶ added in v1.3.0
type IPaginator interface {
// GetPage get current page
GetPage() int
// SetPage set current page
SetPage(page int)
// GetLimit get limit
GetLimit() int
// SetLimit set limit
SetLimit(limit int)
// GetParallelCount get parallel request count
GetParallelCount() int
// SetParallelCount set parallel request count
SetParallelCount(count int)
}
IPaginator interface
type Logger ¶
type Logger interface {
Print(v ...interface{})
Println(v ...interface{})
Printf(format string, v ...interface{})
}
Logger Request logger interface Implement default logger methods
type Paginator ¶ added in v1.3.0
type Paginator struct {
// Page of pagination
Page int `json:"page"`
// Limit for pagination
Limit int `json:"limit"`
// Parallel request
ParallelCount int `json:"parallelCount"`
}
Paginator Base paginator struct Inject the struct into your request forms
func (*Paginator) GetParallelCount ¶ added in v1.3.0
GetParallelCount get count of max parallel requests
func (*Paginator) SetParallelCount ¶ added in v1.3.0
SetParallelCount set max number of parallel request
Click to show internal directories.
Click to hide internal directories.