Moya + Alamofire 验证每个请求
Moya + Alamofire validate every request
我正在使用 Moya
+ Alamofire
并尝试验证每个请求(如 Alamofire.request(.GET, "https://httpbin.org/get").validate()
),但在 Moya
.
内
但是我找不到办法做到这一点。
在您按照 this example:
中所述在 TargetType
实现上实现 validate
属性 后,现在就可以做到这一点
// 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
}
}
}
我正在使用 Moya
+ Alamofire
并尝试验证每个请求(如 Alamofire.request(.GET, "https://httpbin.org/get").validate()
),但在 Moya
.
但是我找不到办法做到这一点。
在您按照 this example:
中所述在TargetType
实现上实现 validate
属性 后,现在就可以做到这一点
// 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
}
}
}