From 20e1b14108dbff16e93d252da6ec8db0a36cf0d4 Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Sun, 14 Feb 2021 17:11:05 -0500 Subject: [PATCH] Update Client documentation --- client.go | 21 +++++++++++++++++++-- 1 file 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 {