We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
对于 restful api 来说, 如 /api/user/:id, mock需要支持以下各种情况
/api/user/:id
GET /api/user/:id POST /api/user PUT /api/user/:id # ....
目前 mock-server 没有针对该场景做优化, 目前只能通过 data.js 导出 function, 并在其中判断 http method 后返回不同的数据
data.js
初步设想如下
/api/user/:id - get.js - post.js - put.js - ....
当命中 /api/user/:id 后, 会再去判断对应的 http method, 执行不同的js文件
http method
和data.js一样, get/post/put等js文件可以直接导出一个数据对象, 也可以导出一个方法
get/post/put
当没有匹配的时候, 如 GET /api/user/123, 但是 /api/user/:id 目录下没有 get.js, 就返回 405 method not allowed
GET /api/user/123
get.js
405 method not allowed
The text was updated successfully, but these errors were encountered:
funkyLover
No branches or pull requests
问题
对于 restful api 来说, 如
/api/user/:id
, mock需要支持以下各种情况GET /api/user/:id POST /api/user PUT /api/user/:id # ....
目前 mock-server 没有针对该场景做优化, 目前只能通过
data.js
导出 function, 并在其中判断 http method 后返回不同的数据优化目标
初步设想如下
当命中
/api/user/:id
后, 会再去判断对应的http method
, 执行不同的js文件和
data.js
一样,get/post/put
等js文件可以直接导出一个数据对象, 也可以导出一个方法当没有匹配的时候, 如
GET /api/user/123
, 但是/api/user/:id
目录下没有get.js
, 就返回405 method not allowed
The text was updated successfully, but these errors were encountered: