//DoRequest execute an http request to the drive
//parameters:
//  pMethod = http request method (GET,..)
//  pUrl = request url
//  pRequestModifierFunc = optional, func to customize request
//  pResultBean = pointer to a struct where to deserialize data
//returns:
//  error in case of error
DoRequest execute an http request to the drive
parameters:
pMethod = http request method (GET,..)
pUrl = request url
pRequestModifierFunc = optional, func to customize request
pResultBean = pointer to a struct where to deserialize data
returns:
error in case of error
// DoRequest execute an http request to the drive // parameters : // pMethod = http request method ( GET .. ) // pUrl = request url // pRequestModifierFunc = optional func to customize request // pResultBean = pointer to a struct where to deserialize data // returns : // error in case of error
func (vSelf *OneDriveClient) DoRequest(pMethod string, pURL string, pRequestModifierFunc func(*http.Request) error, pResultBean interface{}) (vRisError error) {
	var vURL string
	if strings.Contains(pURL, "://") {
		vURL = pURL
	} else {
		vURL = "https://api.onedrive.com/v1.0" + pURL
	}
	if diagnostic.IsLogTrace() {
		diagnostic.LogTrace("OneDriveClient.DoRequest", "Performing request url %s...", vURL)
	}
	vRequest, _ := http.NewRequest(pMethod, vURL, nil)
	if pRequestModifierFunc != nil {
		vModifierError := pRequestModifierFunc(vRequest)
		return vModifierError
	}
	vResponse, vError := vSelf.doRequest(vRequest, 0)
	if vError != nil {
		return diagnostic.NewError("Error performing request", vError)
	}
	vData, vParseDataError := ioutil.ReadAll(vResponse.Body)
	defer vResponse.Body.Close()
	if vParseDataError != nil {
		return diagnostic.NewError("Error parsing response body", vError)
	}
	if diagnostic.IsLogTrace() {
		diagnostic.LogTrace("OneDriveClient.DoRequest", "Response  %s", vData)
	}
	if pResultBean != nil {
		vError = json.Unmarshal(vData, pResultBean)
		if vError != nil {
			return diagnostic.NewError("Error parsing response: %s", vError, vData)
		}
	}
	return nil
}
func ( vSelf * OneDriveClient ) DoRequest ( pMethod string , pURL string , pRequestModifierFunc func ( * http . Request ) error , pResultBean interface { } ) ( vRisError error ) { var vURL string if strings . Contains ( pURL , " " ) { vURL = pURL } else { vURL = " " + pURL } if diagnostic . IsLogTrace ( ) { diagnostic . LogTrace ( " " , " " , vURL ) } vRequest , _ := http . NewRequest ( pMethod , vURL , nil ) if pRequestModifierFunc != nil { vModifierError := pRequestModifierFunc ( vRequest ) return vModifierError } vResponse , vError := vSelf . doRequest ( vRequest , 0 ) if vError != nil { return diagnostic . NewError ( " " , vError ) } vData , vParseDataError := ioutil . ReadAll ( vResponse . Body ) defer vResponse . Body . Close ( ) if vParseDataError != nil { return diagnostic . NewError ( " " , vError ) } if diagnostic . IsLogTrace ( ) { diagnostic . LogTrace ( " " , " " , vData ) } if pResultBean != nil { vError = json . Unmarshal ( vData , pResultBean ) if vError != nil { return diagnostic . NewError ( " " , vError , vData ) } } return nil }
DoRequest execute an http request to the drive
parameters:
pMethod = http request method (GET,..)
pUrl = request url
pRequestModifierFunc = optional, func to customize request
pResultBean = pointer to a struct where to deserialize data
returns:
error in case of error
DoRequest execute an http request to the drive parameters : pMethod = http request method ( GET .. ) pUrl = request url pRequestModifierFunc = optional func to customize request pResultBean = pointer to a struct where to deserialize data returns : error in case of error