import { Zondy } from '../base'
import { defaultValue } from '../util'
/**
* 请求拦截器对象
* @class RequestInterceptor
* @moduleEx ServiceModule
* @param {Object} options 构造参数
* @param {Function} [options.before(config) = 无] 请求发送前会执行的函数
* @param {Function} [options.failure(error) = 无] 请求发送失败会执行的函数
*/
class RequestInterceptor {
constructor(options) {
options = defaultValue(options, {})
/**
* 请求发送前会执行的函数
* @member {String} RequestInterceptor.prototype.before
* */
this.before = defaultValue(options.success, undefined)
/**
* 请求发送失败会执行的函数
* @member {String} RequestInterceptor.prototype.failure
* */
this.failure = defaultValue(options.failure, undefined)
}
}
Zondy.Service.RequestInterceptor = RequestInterceptor
export default RequestInterceptor