// Request will make a request to a given path, with a given body and return
// the result in raw bytes.
Request will make a request to a given path, with a given body and return
the result in raw bytes.
// Request will make a request to a given path with a given body and return // the result in raw bytes .
func (c *Client) Request(path string, method string, body []byte) ([]byte, error) {
	req := fasthttp.AcquireRequest()
	defer fasthttp.ReleaseRequest(req)
	addr := c.url + path
	req.URI().Update(addr)
	req.Header.SetMethod(method)
	req.Header.SetContentType("application/json")
	req.Header.Set("Authorization", "Bearer "+c.APISecret)
	if body != nil {
		req.SetBody(body)
	}
	res := fasthttp.AcquireResponse()
	defer fasthttp.ReleaseResponse(res)
	if err := fasthttp.DoTimeout(req, res, 5*time.Second); err != nil {
		return nil, err
	}
	if res.StatusCode() != http.StatusOK {
		if err := ParseRequestError(res.Body()); err != nil {
			return nil, err
		}
		return nil, &RequestError{
			RequestBody:  req.Body(),
			ResponseBody: res.Body(),
			StatusCode:   res.StatusCode(),
		}
	}
	return res.Body(), nil
}
func ( c * Client ) Request ( path string , method string , body [ ] byte ) ( [ ] byte , error ) { req := fasthttp . AcquireRequest ( ) defer fasthttp . ReleaseRequest ( req ) addr := c . url + path req . URI ( ) . Update ( addr ) req . Header . SetMethod ( method ) req . Header . SetContentType ( " " ) req . Header . Set ( " " , " " + c . APISecret ) if body != nil { req . SetBody ( body ) } res := fasthttp . AcquireResponse ( ) defer fasthttp . ReleaseResponse ( res ) if err := fasthttp . DoTimeout ( req , res , 5 * time . Second ) ; err != nil { return nil , err } if res . StatusCode ( ) != http . StatusOK { if err := ParseRequestError ( res . Body ( ) ) ; err != nil { return nil , err } return nil , & RequestError { RequestBody : req . Body ( ) , ResponseBody : res . Body ( ) , StatusCode : res . StatusCode ( ) , } } return res . Body ( ) , nil }
Request will make a request to a given path, with a given body and return
the result in raw bytes.
Request will make a request to a given path with a given body and return the result in raw bytes .