12345678910111213141516171819202122232425262728293031323334353637 |
- package http_client
- import (
- "das/application/ports"
- "github.com/go-resty/resty/v2"
- "time"
- )
- type Client struct {
- client *resty.Client
- }
- func New() *Client {
- return &Client{
- client: resty.New(),
- }
- }
- func Destroy(client *Client) {
- if client == nil {
- return
- }
- client.client = nil
- }
- func (client *Client) NewRequest(opts ...ports.NewRequestOption) ports.HttpRequest {
- for _, opt := range opts {
- opt(client)
- }
- return &Request{request: client.client.R()}
- }
- func (client *Client) SetTimeout(timeout time.Duration) {
- client.client.SetTimeout(timeout)
- }
|