// Do to execute request and handle repsonse of all services
Do to execute request and handle repsonse of all services
// Do to execute request and handle repsonse of all services
func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error) {
	req.WithContext(ctx)
	resp, err := c.client.Do(req)
	if err != nil {
		select {
		case <-ctx.Done():
			return nil, ctx.Err()
		default:
		}
		if e, ok := err.(*url.Error); ok {
			if urlObj, err := url.Parse(e.URL); err == nil {
				e.URL = urlObj.String()
				return nil, e
			}
		}
		return nil, err
	}
	defer resp.Body.Close()
	response := newResponse(resp)
	err = CheckResponse(resp)
	if err != nil {
		return response, err
	}
	type Response struct {
		Data       interface{}
		Pagination Pagination
	}
	rv := &Response{Data: v}
	err = json.NewDecoder(resp.Body).Decode(rv)
	response.Pagination = rv.Pagination
	return response, err
}
func ( c * Client ) Do ( ctx context . Context , req * http . Request , v interface { } ) ( * Response , error ) { req . WithContext ( ctx ) resp , err := c . client . Do ( req ) if err != nil { select { case <- ctx . Done ( ) : return nil , ctx . Err ( ) default : } if e , ok := err . ( * url . Error ) ; ok { if urlObj , err := url . Parse ( e . URL ) ; err == nil { e . URL = urlObj . String ( ) return nil , e } } return nil , err } defer resp . Body . Close ( ) response := newResponse ( resp ) err = CheckResponse ( resp ) if err != nil { return response , err } type Response struct { Data interface { } Pagination Pagination } rv := & Response { Data : v } err = json . NewDecoder ( resp . Body ) . Decode ( rv ) response . Pagination = rv . Pagination return response , err }
Do to execute request and handle repsonse of all services
Do to execute request and handle repsonse of all services
// If context is cancled then return that error // If the error type is *url.Error