Skip to content

Commit

Permalink
Add uptime page
Browse files Browse the repository at this point in the history
  • Loading branch information
aaparella committed Mar 26, 2017
1 parent 0ba6221 commit 564474b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions main.go
Expand Up @@ -54,6 +54,7 @@ func main() {
go watch(conf)

http.Handle("/", http.FileServer(http.Dir(path.Join(os.TempDir(), "parellagram"))))
http.HandleFunc("/uptime", Uptime)
http.Handle("/styles/", http.StripPrefix("/styles/", http.FileServer(http.Dir(conf.Resources.Styles))))
http.Handle("/images/", http.StripPrefix("/images/", http.FileServer(http.Dir(conf.Resources.Images))))

Expand Down
17 changes: 17 additions & 0 deletions uptime.go
@@ -0,0 +1,17 @@
package main

import (
"fmt"
"net/http"
"time"
)

var launchTime time.Time

func init() {
launchTime = time.Now()
}

func Uptime(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "This server has been running since %v (%v)", launchTime, time.Since(launchTime))
}

0 comments on commit 564474b

Please sign in to comment.