-
Notifications
You must be signed in to change notification settings - Fork 495
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
implemented onConfig
to by pass the request if certain conditions are matched
#120
base: master
Are you sure you want to change the base?
Conversation
8a8869f
to
ba2271f
Compare
Combined Distribution Script |
onRequest = onRequest_; | ||
if (onConfig) { | ||
if (onConfig(config, this) === false) onRequest = null; | ||
} | ||
if (onRequest) return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -97,6 +97,7 @@ interface XhrErrorHandler extends XhrHandler { | |||
} | |||
|
|||
interface Proxy { | |||
onConfig?: (config: XhrRequestConfig, xhrProxy: Hooks) => boolean | void, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改成 onFilter 吧,语义化更好,第二个参数没什么太大用处,可以不传,因为过滤 url 后就可以直接走原生方法了,不用手动调用,切莫过度设计
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改了
新增 api 需要完善一下 markdown 文档 |
新增了 |
close #118
Remarks
Since most requests are
async
, it might not be suitable to do the bypassing inonRequest
.onConfig
is synchronously triggered inxhr.open
, so it can completely bypass the entireopen
+setRequestHeader
(POST request)+send
.Usage