Files
ddns-updater/internal/server/update.go
2024-06-13 09:23:19 +00:00

19 lines
459 B
Go

package server
import (
"net/http"
)
func (h *handlers) update(w http.ResponseWriter, _ *http.Request) {
start := h.timeNow()
errors := h.runner.ForceUpdate(h.ctx) //nolint:contextcheck
duration := h.timeNow().Sub(start)
if len(errors) > 0 {
httpErrors(w, http.StatusInternalServerError, errors)
return
}
w.WriteHeader(http.StatusAccepted)
message := "All records updated successfully in " + duration.String()
_, _ = w.Write([]byte(message))
}