🚀 Feature Request:添加API版本管理 #626
limingchang
started this conversation in
Feature Request
Replies: 2 comments 1 reply
-
实质上,这是一个全局控制请求参数的需求,这个在我们 createAlova({
// ...
beforeRequest(method) {
method.config.params.v = 'xxx'
}
}) |
Beta Was this translation helpful? Give feedback.
0 replies
-
确实,在写这个feature时,我已经考虑到了: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What problem does the new feature need to solve?
希望在创建实体时,添加一个配置以控制请求API的版本,并给予不同的版本号添加方式
How should the new features you expect looks like?
(1)Alova配置项:
enableVersion{
type: Alova.VersionType.URI,
prefix: 'v',
default: '0.1.0'
}
如此配置将会在每个methods请求时,自动请求baseUrl + methods.path + 'v0.1.0'
(2)Alova配置项:
enableVersion{
type: Alova.VersionType.HEADER,
key?: 'version'
default: '0.1.0'
}
如此配置将会在每个methods请求时,自动带上herder : {version:0.1.0},key可选,如设置,则使用设置的key设置header
(3)Alova配置项:
enableVersion{
type: Alova.VersionType.QUERY,
key?: 'v='
default: '0.1.0'
}
如此配置,在每个methods请求时,自动在url上添加?v=0.1.0
(4)Alova配置项:
enableVersion{
type: Alova.VersionType.CUSTOM,
(method,config)=>void
}
如此配置,将交由用户自动处理,在请求发送前添加version标识
同时,在method中,添加配置项version,可覆盖alova全局配置
How important is it to you?
Better to have
Beta Was this translation helpful? Give feedback.
All reactions