其实问题在标题中。REST端点定义如下:
fastify.get('/dir/:path', async (request, reply) => {
let res = await remote.getDir(request.params.path);
return { res: res}
})
一个电话就像
问题在于Fastify将path参数视为URL的延续,并说: "Route GET:/dir// not found"
如标准中所写,斜杠/
被评估为路径段
要归档目标,您需要:
path
为查询参数/
,例如base64范例1:
const fastify = require('fastify')()
fastify.get('/dir', {
schema: {
querystring: {
type: 'object',
required: ['path'],
properties: {
path: { type: 'string' }
}
}
}
},
async function (request, reply) {
return request.query
})
fastify.listen(8080)
// call it with: http://localhost:8080/dir?path=/
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句