optional parameter get request
Milerius opened this issue · comments
Sztergbaum Roman commented
Hello,
Is this possible to define optional parameter like
/foo/:barvalue/?:baroption=1 // < baroption is optional we can say /foo/value and /foo/value/?option=1
What is the best way to achieve that with the router ?
Translate something like that with the framework ?
GET /foo?option=value&bar=otheroption
Sergio VS commented
At now, it's not possible to do that. If you want to do that you must define all urls you would need.
So you could make a PR adding this enhancement.
Sergio VS commented
Hi @Milerius,
I read again your issue and query params are not belong to the path, so it's not responsability of router foresee these args, you must be recover it with ctx.QueryArgs().Peek("<KEY>")
, because the query params are always optionals.
But the optional arguments belonger the path are not supported yet.
Sztergbaum Roman commented
Thank's a lot