Rework addTime

This commit is contained in:
2024-04-16 23:34:20 +02:00
parent 13a85f4218
commit 6dbad4dbc8
4 changed files with 196 additions and 155 deletions

View File

@ -363,7 +363,7 @@ func (server *MyServer) handleTimerAddTime(w http.ResponseWriter, r *http.Reques
return
}
duration, err := parseDuration(r.PathValue("timeToAdd"))
duration, err := parseDuration(r.FormValue("timeToAdd"))
if err != nil {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(err.Error()))
@ -377,7 +377,7 @@ func (server *MyServer) handleTimerAddTime(w http.ResponseWriter, r *http.Reques
return
}
view.TimerView(*timer).Render(context.Background(), w)
view.TimerInfo(*timer).Render(context.Background(), w)
}
func (server *MyServer) handleGetTimerToken(w http.ResponseWriter, r *http.Request) {
@ -559,7 +559,7 @@ func main() {
http.HandleFunc("POST /login", myServer.handlePostLogin)
http.HandleFunc("POST /logout", myServer.handlePostLogout)
http.HandleFunc("GET /timer/{timerId}", myServer.handleTimer)
http.HandleFunc("POST /timer/{timerId}/addTime/{timeToAdd}", myServer.handleTimerAddTime)
http.HandleFunc("POST /timer/{timerId}/addTime", myServer.handleTimerAddTime)
http.HandleFunc("DELETE /timer/{timerId}", myServer.handleDeleteTimer)
http.HandleFunc("POST /timer/{timerId}/resetToken", myServer.handleResetTimerToken)
http.HandleFunc("GET /timer/{timerId}/token", myServer.handleGetTimerToken)