Skip to content

Commit

Permalink
Fix the issue regarding uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanda Kishore committed Jun 6, 2021
1 parent 9b5b4d4 commit 82f2018
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
8 changes: 1 addition & 7 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"embed"
"fmt"
"math"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -46,11 +45,6 @@ func getLogLevel(suppliedLogLevel string) log.Level {
return log.DebugLevel
}

func uptime() string {
elapsedTime := time.Since(StartTime)
return fmt.Sprintf("%d:%d:%d", int(math.Round(elapsedTime.Hours())), int(math.Round(elapsedTime.Minutes())), int(math.Round(elapsedTime.Seconds())))
}

func homePageHandler(rw http.ResponseWriter, r *http.Request) {
var path = r.URL.Path
log.Debug("Serving request for path: ", path)
Expand All @@ -62,7 +56,7 @@ func homePageHandler(rw http.ResponseWriter, r *http.Request) {
}
host, _ := os.Hostname()
homePageTemplate.Execute(rw, map[string]interface{}{
"uptime": uptime(),
"uptime": time.Now().Sub(StartTime).Round(time.Second),
"host": host,
"requestHeaders": r.Header,
"response": "Hello Universe",
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ package main
var VERSION = [...]string{
"1", // MAJOR,
"3", // MINOR,
"1", // PATCH,
"2", // PATCH,
}

0 comments on commit 82f2018

Please sign in to comment.