This commit is contained in:
lbenedar
2026-02-23 16:56:00 +03:00
parent 1f4ba997b7
commit 589d2ae3d8
6 changed files with 136 additions and 0 deletions

24
ch14/1/ch14_1.go Normal file
View File

@@ -0,0 +1,24 @@
package main
import (
"context"
"net/http"
"time"
)
type MsReq struct{}
func CreateTimeoutCtx(msReq time.Duration) func(http.Handler) http.Handler {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
reqCtx := r.Context()
reqCtx = context.WithValue(reqCtx, MsReq{}, msReq)
r.WithContext(reqCtx)
h.ServeHTTP(w, r)
})
}
}
func main() {
}

3
ch14/1/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module gitea.local.lab/Lbenedar/learning_go/ch14/1
go 1.25.0