@@ -148,59 +148,49 @@ fileprivate extension IncomingMessage {
148148 }
149149}
150150
151- @usableFromInline
152- let xmlRpcMethodsRequestKey = " macro.xmlrpc.method-names "
153- @usableFromInline
154- let xmlRpcHelpsRequestKey = " macro.xmlrpc.method-helps "
155- @usableFromInline
156- let xmlRpcMethodSignaturesRequestKey = " macro.xmlrpc.method-signatures "
151+ private enum MethodNames : EnvironmentKey {
152+ static let defaultValue : Set < String > = [ ]
153+ static let loggingKey = " xmlrpc.names "
154+ }
155+ private enum MethodHelps : EnvironmentKey {
156+ static let defaultValue : [ String : String ] = [ : ]
157+ static let loggingKey = " xmlrpc.helps "
158+ }
159+ private enum MethodSignatures : EnvironmentKey {
160+ static let defaultValue : [ String : [ [ XmlRpc . Value . ValueType ] ] ] = [ : ]
161+ static let loggingKey = " xmlrpc.signatues "
162+ }
157163
158164extension IncomingMessage {
159165
160166 fileprivate var knownXmlRpcMethodNames : Set < String > {
161- return ( extra [ xmlRpcMethodsRequestKey ] as? Set < String > ) ?? [ ]
167+ return environment [ MethodNames . self ]
162168 }
163169
164170 @usableFromInline
165171 func addKnownXmlRpcMethod( _ methodName: String ) {
166- if var methods = extra. removeValue ( forKey: xmlRpcMethodsRequestKey)
167- as? Set < String >
168- {
169- methods. insert ( methodName)
170- extra [ xmlRpcMethodsRequestKey] = methods
171- }
172- else {
173- extra [ xmlRpcMethodsRequestKey] = Set ( [ methodName ] )
174- }
172+ environment [ MethodNames . self] . insert ( methodName)
175173 }
176174
177175 @usableFromInline
178- func addHelp( _ help: String , for method: String ) {
179- var helps = extra. removeValue ( forKey: xmlRpcHelpsRequestKey)
180- as? [ String : String ]
181- ?? [ : ]
182- helps [ method] = help
183- extra [ xmlRpcHelpsRequestKey] = helps
176+ func addHelp( _ help: String , for methodName: String ) {
177+ environment [ MethodHelps . self] [ methodName] = help
184178 }
185179
186180 @usableFromInline
187181 func addSignature( _ signature: [ XmlRpc . Value . ValueType ] ,
188182 for method: String )
189183 {
190- var values = extra. removeValue ( forKey: xmlRpcMethodSignaturesRequestKey)
191- as? [ String : [ [ XmlRpc . Value . ValueType ] ] ]
192- ?? [ : ]
184+ var values = environment [ MethodSignatures . self]
193185 values [ method, default: [ ] ] . append ( signature)
194- extra [ xmlRpcMethodSignaturesRequestKey ] = values
186+ environment [ MethodSignatures . self ] = values
195187 }
196188
197189 fileprivate var helps : [ String : String ] {
198- return ( extra [ xmlRpcHelpsRequestKey ] as? [ String : String ] ) ?? [ : ]
190+ return environment [ MethodHelps . self ]
199191 }
200192 fileprivate var signatures : [ String : [ [ XmlRpc . Value . ValueType ] ] ] {
201- return ( extra [ xmlRpcMethodSignaturesRequestKey]
202- as? [ String : [ [ XmlRpc . Value . ValueType ] ] ] )
203- ?? [ : ]
193+ return environment [ MethodSignatures . self]
204194 }
205195}
206196
0 commit comments