packagemainimport("net/http""bytes""fmt""io/ioutil""log""net/url")funcmain(){//Call the http function to create and make a http request}// AuthUser represents the credential for AuthenticationtypeAuthUserstruct{UsernamestringPasswordstring}/*Error prints error@param err error error details@return void*/funcError(errerror,errorMessagestring){iferr!=nil{log.Println(errorMessage)log.Fatal(err)}}/*CreateBaseRequest create the base request for a HTTP request@param method string http request method eg: GET, POST, etc@param url string http request url@param body []byte request body@param user m.AuthUser User authentication details@param verbose boolean prints verbose logs if set to true@return *http.Request HTTP base request*/funcCreateBaseRequest(method,urlstring,body[]byte,userAuthUser,verbosebool)*http.Request{req,err:=http.NewRequest(method,url,bytes.NewBuffer(body))req.SetBasicAuth(user.Username,user.Password)req.Header.Set("Content-Type","application/json")req.Header.Set("Accept","application/json")Error(err,"Error creating the request")ifverbose{fmt.Println("Request Url:",req.URL)fmt.Println("Request Headers:",req.Header)fmt.Println("Request Body:",req.Body)}returnreq}/*HTTPRequest makes a request to the remote server via a proxy server@param user m.AuthUser User authentication details@param req *http.Request HTTP base request@param verbose boolean prints verbose logs if set to true@return []byte response body@return string response status*/funcHTTPRequest(userAuthUser,req*http.Request,verbosebool)([]byte,string){client:=&http.Client{}resp,err:=client.Do(req)Error(err,"There was a problem in making the request")deferresp.Body.Close()respBody,err:=ioutil.ReadAll(resp.Body)Error(err,"There was a problem reading the response body")ifverbose{fmt.Println("Response Headers:",resp.Header)fmt.Println("Response Status:",resp.Status)fmt.Println("Response Body:",string(respBody))}returnrespBody,resp.Status}