Merge pull request #3 from marcinwyszynski/master
Allow passing an arbitrary http.Client
This commit is contained in:
commit
4cf5d6c5fa
1 changed files with 6 additions and 3 deletions
9
rss.go
9
rss.go
|
@ -73,7 +73,11 @@ func (self Date) MustFormat(format string) string {
|
|||
}
|
||||
|
||||
func Read(url string) (*Channel, error) {
|
||||
response, err := http.Get(url)
|
||||
return ReadWithClient(url, http.DefaultClient)
|
||||
}
|
||||
|
||||
func ReadWithClient(url string, client *http.Client) (*Channel, error) {
|
||||
response, err := client.Get(url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -84,8 +88,7 @@ func Read(url string) (*Channel, error) {
|
|||
var rss struct {
|
||||
Channel Channel `xml:"channel"`
|
||||
}
|
||||
err = xmlDecoder.Decode(&rss)
|
||||
if err != nil {
|
||||
if err = xmlDecoder.Decode(&rss); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &rss.Channel, nil
|
||||
|
|
Loading…
Reference in a new issue