Commit 7322b1bc authored by Aksel Baardsen's avatar Aksel Baardsen
Browse files

api timeout by client handled properly using net.Timeout() in HttpError

parent 31494a7b
......@@ -3,6 +3,7 @@ package pkg
import (
"encoding/json"
"fmt"
"net"
"net/http"
"strings"
"time"
......@@ -69,7 +70,7 @@ func getBody(url string, m mashup) error {
func HttpError(w http.ResponseWriter, err error) {
// if timeout happened
if strings.Contains(err.Error(), "Client.Timeout exceeded") {
if err, ok:= err.(net.Error); ok && err.Timeout() {
http.Error(w, "Request to API timed out", http.StatusGatewayTimeout)
return // return if error is already displayed
}
......
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