Skip to content

Commit 0045b93

Browse files
author
winches
committed
fix: 兼容win路径, post请求
1 parent 31ff388 commit 0045b93

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

routes/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ async function routes (fastify, options) {
3535
console.log();
3636

3737
for (const item of mockList) {
38-
fastify.get(item, async (request, reply) => {
38+
newItem = item.replace(/\\/g, '\/')
39+
fastify.get(newItem, async (request, reply) => {
40+
return require(join(mockDir, `${item}.js`))(request, request.query, request.body)
41+
})
42+
fastify.post(newItem, async (request, reply) => {
3943
return require(join(mockDir, `${item}.js`))(request, request.query, request.body)
4044
})
4145
}

0 commit comments

Comments
 (0)