summaryrefslogtreecommitdiff
path: root/gopher/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'gopher/client.go')
-rw-r--r--gopher/client.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/gopher/client.go b/gopher/client.go
index fad9413..163d0cd 100644
--- a/gopher/client.go
+++ b/gopher/client.go
@@ -5,6 +5,7 @@ import (
"errors"
"io"
"net"
+ neturl "net/url"
sr "tildegit.org/tjp/sliderule"
)
@@ -53,3 +54,12 @@ func (c Client) RoundTrip(request *sr.Request) (*sr.Response, error) {
return &sr.Response{Body: bytes.NewBuffer(response)}, nil
}
+
+// Fetch parses a URL string and fetches the gopher resource.
+func (c Client) Fetch(url string) (*sr.Response, error) {
+ u, err := neturl.Parse(url)
+ if err != nil {
+ return nil, err
+ }
+ return c.RoundTrip(&sr.Request{URL: u})
+}