use an interface for client, not a concrete implementation
This commit is contained in:
parent
27b3bcee8a
commit
866bcf91b0
1 changed files with 5 additions and 1 deletions
6
rss.go
6
rss.go
|
@ -12,6 +12,10 @@ import (
|
|||
_ "code.google.com/p/go-charset/data"
|
||||
)
|
||||
|
||||
type Fetcher interface {
|
||||
Get(url string) (resp *http.Response, err error)
|
||||
}
|
||||
|
||||
type Channel struct {
|
||||
Title string `xml:"title"`
|
||||
Link string `xml:"link"`
|
||||
|
@ -76,7 +80,7 @@ func Read(url string) (*Channel, error) {
|
|||
return ReadWithClient(url, http.DefaultClient)
|
||||
}
|
||||
|
||||
func ReadWithClient(url string, client *http.Client) (*Channel, error) {
|
||||
func ReadWithClient(url string, client Fetcher) (*Channel, error) {
|
||||
response, err := client.Get(url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in a new issue