Added config options for http request timeouts

This commit is contained in:
2025-02-12 12:48:10 +11:00
parent e605e6437b
commit 1253c6499d
8 changed files with 91 additions and 4 deletions

21
contexts/request_timer.go Normal file
View File

@@ -0,0 +1,21 @@
package contexts
import (
"context"
"errors"
"time"
)
// Set the start time of the request
func SetStart(ctx context.Context, time time.Time) context.Context {
return context.WithValue(ctx, contextKeyRequestTime, time)
}
// Get the start time of the request
func GetStartTime(ctx context.Context) (time.Time, error) {
start, ok := ctx.Value(contextKeyRequestTime).(time.Time)
if !ok {
return time.Time{}, errors.New("Failed to get start time of request")
}
return start, nil
}