diff --git a/.gitignore b/.gitignore index 66fd13c..663a2a9 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ # Dependency directories (remove the comment below to include it) # vendor/ + +main.go \ No newline at end of file diff --git a/fetch/requests.go b/fetch/requests.go new file mode 100644 index 0000000..32aab0d --- /dev/null +++ b/fetch/requests.go @@ -0,0 +1,30 @@ +package requests + +import ( + "net/http" +) + +func doRequest(method string, url string) (*http.Response, error) { + + req, err := http.NewRequest(method, url, nil) + if err != nil { + return nil, err + } + client := http.Client{} + + req.Header.Set("User-Agent", "go-tools by @skorp || github.com/skorp") + resp, err := client.Do(req) + + if err != nil { + return nil, err + } + defer resp.Body.Close() + + return resp, err +} + +// GET request. +func GET(url string) (*http.Response, error) { + + return doRequest("GET", url) +}