aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-02-14 17:11:05 -0500
committerAdnan Maolood <[email protected]>2021-02-14 17:11:05 -0500
commit20e1b14108dbff16e93d252da6ec8db0a36cf0d4 (patch)
treed1352b3aa72cb1baa31421bad1a9e6deefbea917 /client.go
parentUpdate Response documentation (diff)
downloadgo-gemini-20e1b14108dbff16e93d252da6ec8db0a36cf0d4.tar.xz
go-gemini-20e1b14108dbff16e93d252da6ec8db0a36cf0d4.zip
Update Client documentation
Diffstat (limited to 'client.go')
-rw-r--r--client.go21
1 files changed, 19 insertions, 2 deletions
diff --git a/client.go b/client.go
index bac399b..3b612c1 100644
--- a/client.go
+++ b/client.go
@@ -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 {