aboutsummaryrefslogtreecommitdiff
path: root/http/request/context.go
diff options
context:
space:
mode:
Diffstat (limited to 'http/request/context.go')
-rw-r--r--http/request/context.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/http/request/context.go b/http/request/context.go
index 78014e41..b77365de 100644
--- a/http/request/context.go
+++ b/http/request/context.go
@@ -24,6 +24,7 @@ const (
FlashMessageContextKey
FlashErrorMessageContextKey
PocketRequestTokenContextKey
+ ClientIPContextKey
)
// IsAdminUser checks if the logged user is administrator.
@@ -103,6 +104,11 @@ func PocketRequestToken(r *http.Request) string {
return getContextStringValue(r, PocketRequestTokenContextKey)
}
+// ClientIP returns the client IP address stored in the context.
+func ClientIP(r *http.Request) string {
+ return getContextStringValue(r, ClientIPContextKey)
+}
+
func getContextStringValue(r *http.Request, key ContextKey) string {
if v := r.Context().Value(key); v != nil {
return v.(string)