Moya + Alamofire验证每个请求

时间:2016-08-22 20:38:47

标签: swift alamofire moya

我正在使用Moya + Alamofire,我正在尝试验证每个请求(例如Alamofire.request(.GET, "https://httpbin.org/get").validate())但在Moya内。

但我找不到办法做到这一点。

1 个答案:

答案 0 :(得分:1)

现在可以按this example中所述validate实施TargetType实施// MARK: - TargetType Protocol Implementation extension MyService: TargetType { // ... // Validate setup is not required; defaults to `false` // for all requests unless specified otherwise. var validate: Bool { switch self { case .showUser, .showAccounts: return true case .createUser: return false } } } 属性后实现这一点:

Rc
相关问题