forked from mtusi2026/mtusi2026lab2
feat: persist data in PostgreSQL and add Basic/Bearer sessions in Redis
This commit is contained in:
@@ -1,11 +1,25 @@
|
||||
package handler
|
||||
|
||||
import "net/http"
|
||||
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, _ *http.Request) {
|
||||
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"})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user