mtfosbot/module/apis/apis.go

30 lines
396 B
Go
Raw Normal View History

2018-09-10 10:13:27 +00:00
package apis
import (
"io"
"net/http"
)
type RequestObj struct {
Method string
Url string
Body io.Reader
Headers map[string]string
}
func GetRequest(r RequestObj) (req *http.Request, err error) {
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)
}
}
return
}