github.com/TykTechnologies/tyk/internal/httpctx
No package summary is available.
Package
Files: 2. Third party imports: 0. Imports from organisation: 0. Tests: 0. Benchmarks: 0.
Vars
var selfLoopingValue = NewValue[bool](ctx.SelfLooping)
Types
Value
This type doesn't have documentation.
| Field name | Field type | Comment |
|---|---|---|
| Key |
|
No comment on field. |
type Value[T any] struct {
Key any
}
Functions
func IsSelfLooping
IsSelfLooping returns true if the request is flagged as self-looping, indicating it originates and targets the same service.
func IsSelfLooping(r *http.Request) bool {
return selfLoopingValue.Get(r)
}
Cognitive complexity: 0, Cyclomatic complexity: 1
func NewValue
func NewValue[T any](key any) *Value[T] {
return &Value[T]{Key: key}
}
Cognitive complexity: 1, Cyclomatic complexity: 1
func SetSelfLooping
SetSelfLooping updates the request context with a boolean value indicating whether the request is in a self-looping state.
func SetSelfLooping(r *http.Request, value bool) {
selfLoopingValue.Set(r, value)
}
Cognitive complexity: 0, Cyclomatic complexity: 1
func (*Value[T]) Get
func (v *Value[T]) Get(r *http.Request) (res T) {
if val := r.Context().Value(v.Key); val != nil {
res, _ = val.(T)
}
return
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Value[T]) Set
func (v *Value[T]) Set(r *http.Request, val T) *http.Request {
ctx := context.WithValue(r.Context(), v.Key, val)
h := r.WithContext(ctx)
*r = *h
return h
}
Cognitive complexity: 0, Cyclomatic complexity: 1
Tests
Files: 2. Third party imports: 1. Imports from organisation: 0. Tests: 4. Benchmarks: 0.