mtfosbot/module/apis/apis.go
2018-09-12 00:29:38 +08:00

32 lines
428 B
Go

package apis
import (
"io"
"net/http"
)
// RequestObj -
type RequestObj struct {
Method string
URL string
Body io.Reader
Headers map[string]string
}
// GetRequest -
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
}