Commit 0b9066f3 authored by Aksel Baardsen's avatar Aksel Baardsen
Browse files

added global http client

parent c0cb5b6a
...@@ -8,6 +8,11 @@ import ( ...@@ -8,6 +8,11 @@ import (
"time" "time"
) )
// creates http client for ensuring timely timeouts
var client = http.Client{
Timeout: 5 * time.Second,
}
// allowing access to "overloaded" functions // allowing access to "overloaded" functions
func unfold(m mashup, response *http.Response) error { func unfold(m mashup, response *http.Response) error {
return m.unmarshal(response) return m.unmarshal(response)
...@@ -39,11 +44,6 @@ func (s *Specie) unmarshal(resp *http.Response) error { ...@@ -39,11 +44,6 @@ func (s *Specie) unmarshal(resp *http.Response) error {
// parses http.response as a string used later for parsing // parses http.response as a string used later for parsing
func getBody(url string, m mashup) error { func getBody(url string, m mashup) error {
// creates a client to allow for timeout
client := http.Client{
Timeout: 4 * time.Second,
}
// sends a http request // sends a http request
resp, err := client.Get(url) resp, err := client.Get(url)
if err != nil { if err != nil {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment