chore(solution): pull lab2 solution

This commit is contained in:
2026-11-06 02:34:43 +03:00
parent 0ab3a341aa
commit de2f63b926
41 changed files with 2636 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
package handler
import (
"context"
"net/http"
"time"
)
const readyTimeout = time.Second
func (h *Handler) Live(w http.ResponseWriter, _ *http.Request) {
writeJSON(w, http.StatusOK, healthResponse{Status: "ok"})
}
func (h *Handler) Ready(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), readyTimeout)
defer cancel()
for _, dep := range h.deps {
if err := dep(ctx); err != nil {
h.fail(w, r, err)
return
}
}
writeJSON(w, http.StatusOK, healthResponse{Status: "ok"})
}