MCPcopy Create free account
hub / github.com/imroc/req / SetContext

Method SetContext

request.go:983–988  ·  view source on GitHub ↗

SetContext method sets the context.Context for current Request. It allows to interrupt the request execution if ctx.Done() channel is closed. See https://blog.golang.org/context article and the "context" package documentation. Attention: make sure call SetContext before EnableDumpXXX if you want to

(ctx context.Context)

Source from the content-addressed store, hash-verified

981// Attention: make sure call SetContext before EnableDumpXXX if you want to
982// dump at the request level.
983func (r *Request) SetContext(ctx context.Context) *Request {
984 if ctx != nil {
985 r.ctx = ctx
986 }
987 return r
988}
989
990// SetContextData sets the key-value pair data for current Request, so you
991// can access some extra context info for current Request in hook or middleware.

Callers 3

EnableDumpMethod · 0.95
SetContextFunction · 0.80

Calls

no outgoing calls

Tested by 1