我正在使用Moya
+ Alamofire
,我正在尝试验证每个请求(例如Alamofire.request(.GET, "https://httpbin.org/get").validate()
)但在Moya
内。
但我找不到办法做到这一点。
答案 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