expose the response connection as an io.ReadCloser (like net/http does) (#15)
This commit is contained in:
parent
2ea27a7b34
commit
724979970b
@ -293,7 +293,7 @@ func (d *Directory) ToText() ([]byte, error) {
|
|||||||
type Response struct {
|
type Response struct {
|
||||||
Type ItemType
|
Type ItemType
|
||||||
Dir Directory
|
Dir Directory
|
||||||
Body io.Reader
|
Body io.ReadCloser
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get fetches a Gopher resource by URI
|
// Get fetches a Gopher resource by URI
|
||||||
@ -369,7 +369,7 @@ func Get(uri string) (*Response, error) {
|
|||||||
// FetchFile fetches data, not directory information.
|
// FetchFile fetches data, not directory information.
|
||||||
// Calling this on a DIRECTORY Item type
|
// Calling this on a DIRECTORY Item type
|
||||||
// or unsupported type will return an error.
|
// or unsupported type will return an error.
|
||||||
func (i *Item) FetchFile() (io.Reader, error) {
|
func (i *Item) FetchFile() (io.ReadCloser, error) {
|
||||||
if i.Type == DIRECTORY {
|
if i.Type == DIRECTORY {
|
||||||
return nil, errors.New("cannot fetch a directory as a file")
|
return nil, errors.New("cannot fetch a directory as a file")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user