Commit 137637d4 authored by Aksel Baardsen's avatar Aksel Baardsen
Browse files

uptime is now float64(time.seconds original) && status code fix

parent d057bf9a
......@@ -20,7 +20,7 @@ type Diag struct {
Gbif string `json:"gbif,omitempty"`
Restcountries string `json:"restcountries,omitempty"`
Version string `json:"version,omitempty"`
Uptime int `json:"uptime,omitempty"`
Uptime float64 `json:"uptime,omitempty"`
}
// sets up the struct above
......@@ -28,9 +28,9 @@ func GetDiag(d* Diag) error {
// gets status of GBIF api, returns appropriate error
if err := getGbifStatus(d); err != nil{
// if it was a timeout caused by the http.client
if strings.Contains(err.Error(), "error occured while contacting") {
d.Gbif = "503: Request timed out"
// if it was a timeout caused by the http.client there was no returned status code of API
if strings.Contains(err.Error(), "error occurred while contacting") {
d.Gbif = "The server did not give a timely response: No status code returned"
} else {
return err
}
......@@ -38,9 +38,9 @@ func GetDiag(d* Diag) error {
// gets status of restcountries api, returns appropriate error
if err := getRestStatus(d); err != nil {
// if it was a timeout caused by the http.client
if strings.Contains(err.Error(), "error occured while contacting") {
d.Gbif = "503: Request timed out"
// if it was a timeout caused by the http.client there was no returned status code of API
if strings.Contains(err.Error(), "error occurred while contacting") {
d.Gbif = "The server did not give a timely response: No status code returned"
} else {
return err
}
......@@ -78,5 +78,5 @@ func getRestStatus(d *Diag) error {
// Returns application uptime in seconds
func getUptime(d *Diag) {
up := time.Since(startTime).Seconds()
d.Uptime = int(up)
d.Uptime = up
}
\ No newline at end of file
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