diff options
author | 2024-03-19 14:29:09 +0100 | |
---|---|---|
committer | 2024-03-19 20:21:23 -0700 | |
commit | 9df12177ebe2e710eea4d322c57ff5c928e84059 (patch) | |
tree | e50ad2d325c7bb1f15c7f38eca4c436125a888cf /internal/http/request/context.go | |
parent | a78d1c79da81dcf2a40d65b0a41d8164e5b4f6b1 (diff) | |
download | v2-9df12177ebe2e710eea4d322c57ff5c928e84059.tar.gz v2-9df12177ebe2e710eea4d322c57ff5c928e84059.tar.zst v2-9df12177ebe2e710eea4d322c57ff5c928e84059.zip |
Minor idiomatic pass on internal/http/request/context.go
Diffstat (limited to '')
-rw-r--r-- | internal/http/request/context.go | 32 |
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 } |