-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.go
48 lines (42 loc) · 1006 Bytes
/
models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package gofetch
import (
"bytes"
"io"
"net/http"
"time"
)
// Client is a simple API client that makes HTTP requests.
// It contains the status code, response body, error information,
// response headers, debug information, configuration, and an HTTP client.
type Client struct {
StatusCode int
Body string
Error error
ResponseHeaders map[string]string
debugInfo bytes.Buffer
Config Config
httpClient *http.Client
}
// Header defines the structure to model API header key and values.
type Header struct {
Key string
Value string
}
// Query defines a way to easily specify query parameters
type Query struct {
Key string
Value string
}
// requestData is a struct that holds the data for an API request.
type requestData struct {
method string
url string
query []Query
body io.Reader
headers []Header
}
// Config is used to store the configuration for the client
type Config struct {
Timeout time.Duration
Debug bool
}