|
|
|
@ -75,6 +75,9 @@ type client struct { |
|
|
|
|
// Supported URL schemas:
|
|
|
|
|
// - gemini
|
|
|
|
|
// - http/https
|
|
|
|
|
//
|
|
|
|
|
// Some schemas automatically return success:
|
|
|
|
|
// - mailto
|
|
|
|
|
func NewClient(opts *ClientOpts) Client { |
|
|
|
|
return &client{*opts.withDefaults()} |
|
|
|
|
} |
|
|
|
@ -240,6 +243,12 @@ func (c *client) getHTTP( |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *client) noOpGet() ( |
|
|
|
|
string, io.ReadCloser, error, |
|
|
|
|
) { |
|
|
|
|
return "", emptyReadCloser(), nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *client) get( |
|
|
|
|
ctx context.Context, url URL, redirectDepth int, |
|
|
|
|
) ( |
|
|
|
@ -252,6 +261,8 @@ func (c *client) get( |
|
|
|
|
return c.getGemini(ctx, url, redirectDepth) |
|
|
|
|
case "http", "https": |
|
|
|
|
return c.getHTTP(ctx, url, redirectDepth) |
|
|
|
|
case "mailto": |
|
|
|
|
return c.noOpGet() |
|
|
|
|
default: |
|
|
|
|
return "", nil, fmt.Errorf("unsupported scheme %q", scheme) |
|
|
|
|
} |
|
|
|
|