You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: Sources/Hummingbird/Server/RequestContext.swift
+12-2
Original file line number
Diff line number
Diff line change
@@ -54,8 +54,18 @@ public struct CoreRequestContextStorage: Sendable {
54
54
}
55
55
}
56
56
57
-
/// Protocol that all request contexts should conform to. Holds data associated with
58
-
/// a request. Provides context for request processing
57
+
/// Protocol that all request contexts should conform to. A RequestContext is a statically typed metadata container for information
58
+
/// that is associated with a ``Request``, and is therefore instantiated alongside the request.
59
+
///
60
+
/// It's passed along the whole middleware chain through to the route. This allows middleware and the route to share this metadata.
61
+
///
62
+
/// Typical use of a context includes:
63
+
/// - The origin that sent the request (IP address or otherwise)
64
+
/// - The identity, such as a user, that is associated with this request
65
+
///
66
+
/// The context is a statically typed metadata container for the duration of a single request. It's used to store values between middleware and routes such as the user's identity.
67
+
///
68
+
/// The lifetime of a RequestContext should not exceed that of the request.
0 commit comments