如何使用Moya在HTTP标头字段中获得响应

时间:2017-03-16 07:03:47

标签: ios swift http-headers moya

我已经按照以下方式配置了我的提供商:

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标头字段中获得响应,我只能在正文中获取字段。

0 个答案:

没有答案