Commit b30b5ed 1 parent 56336d7 commit b30b5ed Copy full SHA for b30b5ed
File tree 1 file changed +13
-2
lines changed
Sources/Hummingbird/Server
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,19 @@ 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.
67
+ /// It's used to store values between middleware and routes such as the user's identity.
68
+ ///
69
+ /// The lifetime of a RequestContext should not exceed that of the request.
59
70
public protocol RequestContext : InitializableFromSource , RequestContextSource {
60
71
associatedtype Source : RequestContextSource = ApplicationRequestContextSource
61
72
associatedtype Decoder : RequestDecoder = JSONDecoder
You can’t perform that action at this time.
0 commit comments