Closed rgrenonlkr closed 4 years ago
Hi @rgrenonlkr, can you bring more context of your source code? I can't repro this issue on my side.
Please see an example here you can use:
'use strict'
const service = require('restana')({})
const router = service.newRouter()
router.post('/params', (req, res) => {
res.send({ query: req.query })
})
service.use('/router', router)
service.start()
curl --location --request POST 'http://localhost:3000/router/params?age=30'
Hi,
I changed the paths/pattern of your example to match those used in my initial post. Then I get the 404
'use strict'
const service = require('restana')({})
const router = service.newRouter()
router.post('/', (req, res) => {
res.send({ query: req.query })
})
service.use('/router/params', router)
service.start()
EDIT : wording
Hi, now I get your problem.
Unfortunately, this is a limitation from how the router works in the low level, in this case with middlewares and routers. You can see more details at: https://github.com/lukeed/regexparam/blob/master/src/index.js, loose
parameter.
A workaround is to use: POST http://localhost:3000/router/params/
as endpoint, see ending /
Regards
Hi,
You're totally right !
My code defines this pattern ...endpoint/?params
or ...endpoint
But I expect it to match ...endpoint?params
Since this is a computer-to-computer API it will be easier for me specify the mandatory / when using params.
Thanks a lot for your help
Hello,
When adding a query string to a POST request it returns 404
code style :
service.use("/path/to/entity", router_entity);
router_entity defines :
router.post("/", async (req, res, next) => {
I tried with and without swagger middleware but got same result.
Any advise ?
Regards,