aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-02-23 18:56:18 -0500
committerAdnan Maolood <[email protected]>2021-02-23 18:56:18 -0500
commitb3e8d9ccf3b548347e828b2cabffd4eebd475a7c (patch)
tree6e6fabdb87d8a73c38e664d6f6890d4bc6cb1a9d
parentUse HandlerFunc to implement StatusHandler (diff)
downloadgo-gemini-b3e8d9ccf3b548347e828b2cabffd4eebd475a7c.tar.xz
go-gemini-b3e8d9ccf3b548347e828b2cabffd4eebd475a7c.zip
client: Clarify usage of contexts
-rw-r--r--client.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/client.go b/client.go
index 44191c6..5d7e4f5 100644
--- a/client.go
+++ b/client.go
@@ -30,8 +30,9 @@ type Client struct {
}
// Get sends a Gemini request for the given URL.
-// If the provided context is canceled or times out, the request
-// is aborted and the context's error is returned.
+// The context controls the entire lifetime of a request and its response:
+// obtaining a connection, sending the request, and reading the response
+// header and body.
//
// An error is returned if there was a Gemini protocol error.
// A non-2x status code doesn't cause an error.
@@ -48,15 +49,14 @@ func (c *Client) Get(ctx context.Context, url string) (*Response, error) {
}
// Do sends a Gemini request and returns a Gemini response.
-// If the provided context is canceled or times out, the request
-// is aborted and the context's error is returned.
+// The context controls the entire lifetime of a request and its response:
+// obtaining a connection, sending the request, and reading the response
+// header and body.
//
// 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 user is expected to close the Response.
-//
-// Generally Get will be used instead of Do.
func (c *Client) Do(ctx context.Context, req *Request) (*Response, error) {
if ctx == nil {
panic("nil context")