<commit_before>## go-requestor
[![GoDoc](https://godoc.org/github.com/scottdware/go-requestor?status.svg)](https://godoc.org/github.com/scottdware/go-requestor) [![Travis-CI](https://travis-ci.org/scottdware/go-requestor.svg?branch=master)](https://travis-ci.org/scottdware/go-requestor)
[![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/scottdware/go-requestor/master/LICENSE)

A Go package that makes calling RESTful API's easy.

### Example

To send a request, you first specify some options such as the method (GET, POST, PUT, etc.), Content-Type, any additional headers, query parameters, etc.:

```Go
req := &requestor.Options{
	Method:      "get",
	ContentType: "application/json",
	Auth:        []string{"user", "<PASSWORD>"},
	Query: map[string]string{
		"another_param": "somevalue",
		"more_stuff": "more-values",
	},
}
```

Then, call the `Send()` function to issue the request, specifying the URL and the options you defined above:

```Go
data := requestor.Send("https://someurl/api/v1.0/stuff?default_param=something", req)
if data.Error != nil {
	fmt.Println(data.Error)
}
```

The entire request with any additional query parameters defined will look like the following when sent to the server:

```
https://someurl/api/v1.0/stuff?another_param=somevalue&default_param=something&more_stuff=more-values
```

> If there was any type of error in your request, it will be defined in the `Error` field of the returned struct. This is why the above error check looks a bit different than how you would normally check for errors in Go.

The returned data is a struct with the following values:

```Go
type HTTPData struct {
	Status  string
	Code    int
	Headers http.Header<commit_msg>Added header examples<commit_after>## go-requestor
[![GoDoc](https://godoc.org/github.com/scottdware/go-requestor?status.svg)](https://godoc.org/github.com/scottdware/go-requestor) [![Travis-CI](https://travis-ci.org/scottdware/go-requestor.svg?branch=master)](https://travis-ci.org/scottdware/go-requestor)
[![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/scottdware/go-requestor/master/LICENSE)

A Go package that makes calling RESTful API's easy.

### Example

To send a request, you first specify some options such as the method (GET, POST, PUT, etc.), Content-Type, any additional headers, query parameters, etc.:

```Go
req := &requestor.Options{
	Method:      "get",
	ContentType: "application/json",
	Auth:        []string{"user", "<PASSWORD>"},
	Headers: map[string]string{
		"Custom-Header": "value",
	},
	Query: map[string]string{
		"another_param": "somevalue",
		"more_stuff": "more-values",
	},
}
```

Then, call the `Send()` function to issue the request, specifying the URL and the options you defined above:

```Go
data := requestor.Send("https://someurl/api/v1.0/stuff?default_param=something", req)
if data.Error != nil {
	fmt.Println(data.Error)
}
```

The entire request with any additional query parameters defined will look like the following when sent to the server:

```
https://someurl/api/v1.0/stuff?another_param=somevalue&default_param=something&more_stuff=more-values
```

> If there was any type of error in your request, it will be defined in the `Error` field of the returned struct. This is why the above error check looks a bit different than how you would normally check for errors in Go.

The returned data is a struct with the following values:

```Go
type HTTPData struct {
	Status  string
	Code    int
	Headers http.Header
{'fraction_non_alphanumeric': 0.13749649957994958, 'fraction_numerical': 0.0022402688322598714, 'mean_word_length': 4.904132231404959, 'pattern_counts': {'":': 5, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6451880', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1123, 'n_words': 333}