29 lines
461 B
Go
29 lines
461 B
Go
package goboru
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
type Module interface {
|
|
Query([]string) ([]Media, error)
|
|
}
|
|
|
|
type Media struct {
|
|
Source string
|
|
MD5 string
|
|
Tags []string
|
|
}
|
|
|
|
func (m Media) Content() (rc io.ReadCloser, err error) {
|
|
client := http.Client{Timeout: 0, Transport: &http.Transport{ResponseHeaderTimeout: 10 * time.Second}}
|
|
|
|
var resp *http.Response
|
|
if resp, err = client.Get(m.Source); err != nil {
|
|
return
|
|
}
|
|
rc = resp.Body
|
|
return
|
|
}
|