MCPcopy Create free account
hub / github.com/kataras/iris / getOrSetKey

Function getOrSetKey

cache/client/handler.go:100–127  ·  view source on GitHub ↗
(ctx *context.Context)

Source from the content-addressed store, hash-verified

98}
99
100func getOrSetKey(ctx *context.Context) string {
101 if key := GetKey(ctx); key != "" {
102 return key
103 }
104
105 // Note: by-default the rules(ruleset pkg)
106 // explicitly ignores the cache handler
107 // execution on authenticated requests
108 // and immediately runs the next handler:
109 // if !h.rule.Claim(ctx) ...see `Handler` method.
110 // So the below two lines are useless,
111 // however we add it for cases
112 // that the end-developer messedup with the rules
113 // and by accident allow authenticated cached results.
114 username, password, _ := ctx.Request().BasicAuth()
115 authPart := username + strings.Repeat("*", len(password))
116
117 key := ctx.Method() + authPart
118
119 u := ctx.Request().URL
120 if !u.IsAbs() {
121 key += ctx.Scheme() + ctx.Host()
122 }
123 key += u.String()
124
125 SetKey(ctx, key)
126 return key
127}
128
129func (h *Handler) ServeHTTP(ctx *context.Context) {
130 // check for pre-cache validators, if at least one of them return false

Callers 1

ServeHTTPMethod · 0.85

Calls 7

GetKeyFunction · 0.85
SetKeyFunction · 0.85
RequestMethod · 0.80
SchemeMethod · 0.80
HostMethod · 0.80
MethodMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…