admin: add a route to simulate time.json on backend machine
This commit is contained in:
parent
acfd7a74ae
commit
09754e2eec
25
admin/time.go
Normal file
25
admin/time.go
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"path"
|
||||||
|
|
||||||
|
"srs.epita.fr/fic-server/admin/api"
|
||||||
|
"srs.epita.fr/fic-server/frontend/time"
|
||||||
|
"srs.epita.fr/fic-server/settings"
|
||||||
|
|
||||||
|
"github.com/julienschmidt/httprouter"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
api.Router().GET("/time.json", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
|
if config, err := settings.ReadSettings(path.Join(api.TeamsDir, settings.SettingsFile)); err != nil {
|
||||||
|
http.Error(w, fmt.Sprintf("{\"errmsg\":\"%q\"}", err), http.StatusInternalServerError)
|
||||||
|
} else {
|
||||||
|
time.ChallengeStart = config.Start
|
||||||
|
time.ChallengeEnd = config.End
|
||||||
|
time.TimeHandler{}.ServeHTTP(w, r)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user