diff options
Diffstat (limited to 'request_handlers.go')
-rw-r--r-- | request_handlers.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/request_handlers.go b/request_handlers.go index adf5535..187d759 100644 --- a/request_handlers.go +++ b/request_handlers.go @@ -32,9 +32,11 @@ func (c Client) get(endpoint string) ([]byte, error) { req, _ := http.NewRequest(http.MethodGet, endpoint, nil) // add authorization headers - // TODO: implement client auth - //req.Header.Add("X-MAL-CLIENT-ID", c.ClientAuth) - req.Header.Add("Authorization", c.MainAuth) + if c.ClientAuthOnly { + req.Header.Add("X-MAL-CLIENT-ID", c.ClientAuth) + } else { + req.Header.Add("Authorization", c.MainAuth) + } // send request res, err := c.httpClient.Do(req) @@ -60,6 +62,10 @@ func (c Client) get(endpoint string) ([]byte, error) { } func (c Client) delete(endpoint string) error { + if c.ClientAuthOnly { + return ErrClientAuthNotSupported + } + // can safely ignore error with http.NewRequest req, _ := http.NewRequest(http.MethodDelete, endpoint, nil) @@ -95,6 +101,10 @@ func (c Client) delete(endpoint string) error { } func (c Client) put(endpoint string, params url.Values) ([]byte, error) { + if c.ClientAuthOnly { + return []byte{}, ErrClientAuthNotSupported + } + encodedParams := params.Encode() // can safely ignore error with http.NewRequest |