diff options
| author | Adnan Maolood <[email protected]> | 2021-02-14 17:11:05 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-02-14 17:11:05 -0500 |
| commit | 20e1b14108dbff16e93d252da6ec8db0a36cf0d4 (patch) | |
| tree | d1352b3aa72cb1baa31421bad1a9e6deefbea917 /client.go | |
| parent | Update Response documentation (diff) | |
| download | go-gemini-20e1b14108dbff16e93d252da6ec8db0a36cf0d4.tar.xz go-gemini-20e1b14108dbff16e93d252da6ec8db0a36cf0d4.zip | |
Update Client documentation
Diffstat (limited to 'client.go')
| -rw-r--r-- | client.go | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -31,7 +31,15 @@ type Client struct { Timeout time.Duration } -// Get performs a Gemini request for the given URL. +// Get sends a Gemini request for the given URL. +// +// An error is returned if there was a Gemini protocol error. +// A non-2x status code doesn't cause an error. +// +// If the returned error is nil, the Response will contain a non-nil Body +// which the user is expected to close. +// +// For more control over requests, use NewRequest and Client.Do. func (c *Client) Get(url string) (*Response, error) { req, err := NewRequest(url) if err != nil { @@ -40,7 +48,16 @@ func (c *Client) Get(url string) (*Response, error) { return c.Do(req) } -// Do performs a Gemini request and returns a Gemini response. +// Do sends a Gemini request and returns a Gemini response, following +// policy as configured on the client. +// +// An error is returned if there was a Gemini protocol error. +// A non-2x status code doesn't cause an error. +// +// If the returned error is nil, the Response will contain a non-nil Body +// which the user is expected to close. +// +// Generally Get will be used instead of Do. func (c *Client) Do(req *Request) (*Response, error) { // Punycode request URL if punycode, err := punycodeHost(req.URL.Host); err != nil { |