import Hummingbird import Infrastructure import NIOCore /// The website's request context. /// /// Extends the core request storage with the connected client's address, so ``RateLimitMiddleware`` can key its budgets per client. public struct WebsiteRequestContext: RemoteAddressRequestContext { // MARK: Properties /// The core request context storage Hummingbird requires. public var coreContext: CoreRequestContextStorage /// The address of the connected client, captured from the source channel. public let remoteAddress: SocketAddress? // MARK: Initializers /// Creates a request context for the given source. /// - Parameter source: the source the context is initialized from. public init( source: Source, ) { self.coreContext = .init(source: source) self.remoteAddress = source.channel.remoteAddress } }