lab4: вложения в S3 (MinIO), reconciler PostgreSQL↔S3, тесты и CI

This commit is contained in:
2026-11-04 20:11:33 +03:00
parent ec540a1a72
commit 77b6e5c2c7
86 changed files with 6921 additions and 2 deletions
@@ -0,0 +1,29 @@
package middleware
import (
"crypto/rand"
"fmt"
"net/http"
"github.com/charawein/mtusi2026lab4/internal/transport/httputil"
)
func RequestID(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
id := r.Header.Get("X-Request-Id")
if id == "" {
id = newRequestID()
}
w.Header().Set("X-Request-Id", id)
ctx := httputil.ContextWithRequestID(r.Context(), id)
next.ServeHTTP(w, r.WithContext(ctx))
})
}
func newRequestID() string {
var b [12]byte
if _, err := rand.Read(b[:]); err != nil {
panic(fmt.Sprintf("crypto/rand failed: %v", err))
}
return fmt.Sprintf("%x", b[:])
}