Gemini/GeminiProtocol/Message+Gemini.swift

34 lines
808 B
Swift
Raw Normal View History

2020-07-13 03:09:37 +00:00
//
// Message+Gemini.swift
// Gemini
//
// Created by Shadowfacts on 7/12/20.
//
import Network
private let requestKey = "gemini_request"
private let responseHeaderKey = "gemini_response_header"
extension NWProtocolFramer.Message {
convenience init(geminiRequest request: GeminiRequest) {
self.init(definition: GeminiProtocol.definition)
self[requestKey] = request
}
convenience init(geminiResponseHeader header: GeminiResponseHeader) {
self.init(definition: GeminiProtocol.definition)
self[responseHeaderKey] = header
}
var geminiRequest: GeminiRequest? {
self[requestKey] as? GeminiRequest
}
var geminiResponseHeader: GeminiResponseHeader? {
self[responseHeaderKey] as? GeminiResponseHeader
}
}