我已经按照以下方式配置了我的提供商:
lazy var provider: RxMoyaProvider<LiveNetworkAPI> = {
let endpointClosure = { (target: LiveNetworkAPI) -> Endpoint<LiveNetworkAPI> in
let defaultEndpoint = MoyaProvider.defaultEndpointMapping(for: target)
return defaultEndpoint.adding(newHTTPHeaderFields: ["Device-System-Version": "iOS \(UIDevice.current.systemVersion)",
"Device-Version": Device.version().rawValue
])
}
return RxMoyaProvider<LiveNetworkAPI>(endpointClosure: endpointClosure, plugins: [NetworkLoggerPlugin(verbose: true), self.pluginLoading])
}()
但我不知道如何在HTTP标头字段中获得响应,我只能在正文中获取字段。