mtgbot/modules/apiact/apiact.go

29 lines
436 B
Go

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) {
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
}