frontend: log time.json GET
This commit is contained in:
parent
f88068c08d
commit
1129bd68be
1 changed files with 3 additions and 0 deletions
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -19,6 +20,8 @@ type timeObject struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t TimeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (t TimeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log.Printf("Handling %s request from %s: %s [%s]\n", r.Method, r.RemoteAddr, r.URL.Path, r.UserAgent())
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
if j, err := json.Marshal(timeObject{t.StartTime.Unix(), time.Now().Unix(), int(t.Duration.Seconds())}); err != nil {
|
if j, err := json.Marshal(timeObject{t.StartTime.Unix(), time.Now().Unix(), int(t.Duration.Seconds())}); err != nil {
|
||||||
|
|
Reference in a new issue