2019-01-09 06:01:13 +00:00
|
|
|
package apiact
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
// RequestObject -
|
|
|
|
type RequestObject struct {
|
|
|
|
Method string
|
|
|
|
URL string
|
|
|
|
Body io.Reader
|
|
|
|
Headers map[string]string
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetRequest -
|
|
|
|
func GetRequest(r RequestObject) (req *http.Request, err error) {
|
2019-01-14 10:06:10 +00:00
|
|
|
req, err = http.NewRequest(r.Method, r.URL, r.Body)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if len(r.Headers) > 0 {
|
|
|
|
for k, v := range r.Headers {
|
|
|
|
req.Header.Set(k, v)
|
|
|
|
}
|
|
|
|
}
|
2019-01-09 06:01:13 +00:00
|
|
|
return
|
|
|
|
}
|