Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MultipartFile ¶ added in v0.0.4
type Request ¶ added in v0.0.4
type Request[T ResponseSuccessData, E ResponseErrorData] struct { Ctx context.Context Client *RestClient HttpMethod string // use http.methodXXX Cache *cacheDB.Cache[T] Path string Headers map[string]string Body any MultipartFields map[string]any // contains filtered or unexported fields }
Request struct for http requests
func (Request[T, E]) Call ¶ added in v0.0.4
func (req Request[T, E]) Call() (response ResponseData[T, E])
Call executes the HTTP request and handles retries and caching.
It validates the request, checks cache, executes the request with retries, handles success, and logs errors. Returns the response data.
type RequestData ¶
type RequestData interface { any }
RequestData interface to encapsulate request data
type ResponseData ¶
type ResponseData[T any, E any] interface { StatusCode() int Headers() http.Header SuccessBody() *T ErrorBody() *E Error() error IsInformationalResponse() bool IsSuccessfulResponse() bool IsRedirectionMessage() bool IsClientErrorResponse() bool IsServerErrorResponse() bool HasError() bool HasSuccess() bool }
ResponseData interface to encapsulate response data with Status code, Headers, Success body, Error body and Error
type ResponseErrorData ¶
type ResponseErrorData interface { any }
ResponseErrorData interface to encapsulate response error data
type ResponseSuccessData ¶ added in v0.0.4
type ResponseSuccessData interface { any }
ResponseSuccessData interface to encapsulate response success data
type RestClient ¶
type RestClient struct {
// contains filtered or unexported fields
}
RestClient struct with http client and circuit breaker name: Represents the name of the REST client. baseURL: Holds the base URL of the REST client. retries: Specifies the number of retries for the REST client. retrySleep: Indicates the time to sleep between retries. client: Is a pointer to an http.Client for making HTTP requests. cb: Points to a circuitbreaker.CircuitBreaker for managing circuit breaking behavior in the REST client.
func NewRestClient ¶
func NewRestClient(config *RestClientConfig) *RestClient
NewRestClient creates a new REST client based on the provided configuration.
config: A pointer to RestClientConfig containing the configuration details for the REST client. Returns a pointer to RestClient.