Retrieve time through X-FIC-Time header instead of time.json

This commit is contained in:
nemunaire 2018-08-17 22:17:51 +02:00 committed by Pierre-Olivier Mercier
commit 6034246015
11 changed files with 107 additions and 131 deletions

View file

@ -8,6 +8,7 @@ import (
"log"
"net/http"
"strconv"
"time"
"srs.epita.fr/fic-server/libfic"
@ -60,6 +61,8 @@ func apiHandler(f DispatchFunction) func(http.ResponseWriter, *http.Request, htt
resStatus = http.StatusNotFound
}
w.Header().Set("X-FIC-Time", fmt.Sprintf("%f", float64(time.Now().UnixNano()/1000)/1000000))
if str, found := ret.(string); found {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(resStatus)