Skip to content
New issue

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 支持 #30

Open
funkyLover opened this issue Jan 13, 2021 · 0 comments
Open

restful api 支持 #30

funkyLover opened this issue Jan 13, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@funkyLover
Copy link
Owner

问题

对于 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
  - get.js
  - post.js
  - put.js
  - ....

当命中 /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

@funkyLover funkyLover added the enhancement New feature or request label Jan 13, 2021
@funkyLover funkyLover self-assigned this Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant