ServerCallContext.swift 714 B

123456789101112131415161718192021222324
  1. import Foundation
  2. import SwiftProtobuf
  3. import NIO
  4. import NIOHTTP1
  5. /// Protocol declaring a minimum set of properties exposed by *all* types of call contexts.
  6. public protocol ServerCallContext: class {
  7. /// The event loop this call is served on.
  8. var eventLoop: EventLoop { get }
  9. /// Generic metadata provided with this request.
  10. var request: HTTPRequestHead { get }
  11. }
  12. /// Base class providing data provided to the framework user for all server calls.
  13. open class ServerCallContextBase: ServerCallContext {
  14. public let eventLoop: EventLoop
  15. public let request: HTTPRequestHead
  16. public init(eventLoop: EventLoop, request: HTTPRequestHead) {
  17. self.eventLoop = eventLoop
  18. self.request = request
  19. }
  20. }