Skip to content
Snippets Groups Projects
Commit 12827928 authored by Aksel Baardsen's avatar Aksel Baardsen
Browse files

fixed app uptime

parent e4be5e7e
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,6 @@ import (
"net/http"
)
//returns json ready for parsing as string
func main() {
......
......@@ -3,17 +3,21 @@ package pkg
import (
"log"
"net/http"
"time"
)
const gbifApi = "http://api.gbif.org/v1/"
const restApi = "https://restcountries.eu/rest/v2"
var startTime time.Time
type Diag struct {
func init() {
startTime = time.Now()
}
type Diag struct {
Gbif int `json:"gbif"`
Restcountries int `json:"restcountries"`
Version string `json:"version"`
Uptime string `json:"uptime"`
Uptime float64 `json:"uptime"`
}
func GetDiag(d* Diag) {
......@@ -23,7 +27,6 @@ func GetDiag(d* Diag) {
getUptime(d)
}
func getGbifStatus(d *Diag) {
resp, err := http.Get(gbifApi)
if err != nil {
......@@ -44,6 +47,8 @@ func getVersion(d *Diag) {
d.Version = "v1"
}
// Returns application uptime in seconds
func getUptime(d *Diag) {
d.Uptime = "42sec"
up := time.Since(startTime).Seconds()
d.Uptime = up
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment