chore: port lab 2 solution

This commit is contained in:
kk10
2026-10-16 19:50:49 +03:00
parent 0ab3a341aa
commit 6e0829e628
71 changed files with 4305 additions and 6 deletions
+17
View File
@@ -0,0 +1,17 @@
package middleware
import (
"context"
"net/http"
"time"
)
func RequestTimeout(d time.Duration) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), d)
defer cancel()
next.ServeHTTP(w, r.WithContext(ctx))
})
}
}