summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--internal/http/request/context.go32
1 files changed, 8 insertions, 24 deletions
diff --git a/internal/http/request/context.go b/internal/http/request/context.go
index b2ce54cf..ba6ee40d 100644
--- a/internal/http/request/context.go
+++ b/internal/http/request/context.go
@@ -37,14 +37,10 @@ const (
func WebAuthnSessionData(r *http.Request) *model.WebAuthnSession {
if v := r.Context().Value(WebAuthnDataContextKey); v != nil {
- value, valid := v.(model.WebAuthnSession)
- if !valid {
- return nil
+ if value, valid := v.(model.WebAuthnSession); valid {
+ return &value
}
-
- return &value
}
-
return nil
}
@@ -151,39 +147,27 @@ func ClientIP(r *http.Request) string {
func getContextStringValue(r *http.Request, key ContextKey) string {
if v := r.Context().Value(key); v != nil {
- value, valid := v.(string)
- if !valid {
- return ""
+ if value, valid := v.(string); valid {
+ return value
}
-
- return value
}
-
return ""
}
func getContextBoolValue(r *http.Request, key ContextKey) bool {
if v := r.Context().Value(key); v != nil {
- value, valid := v.(bool)
- if !valid {
- return false
+ if value, valid := v.(bool); valid {
+ return value
}
-
- return value
}
-
return false
}
func getContextInt64Value(r *http.Request, key ContextKey) int64 {
if v := r.Context().Value(key); v != nil {
- value, valid := v.(int64)
- if !valid {
- return 0
+ if value, valid := v.(int64); valid {
+ return value
}
-
- return value
}
-
return 0
}