fasthttp / router

Router implementation for fasthttp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

optional parameter get request

Milerius opened this issue · comments

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 

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.

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.

Thank's a lot