miso miso - 1 year ago 66
reST (reStructuredText) Question

Can I prefix with $ (dollar sign) my URL query string parameters safely?

I am starting to implement filtering through query strings in my API REST application where I can perform filtering on any field passed to a entity in my database. But there are especial parameters that I want to differentiate like;

, etc from the rest of fields that will be used to filter the collection.

I want to avoid using an implementation like:


Because I will need to make a custom parser to the

My desired structure is something more plain, like this:


So, all the properties that aren't prefixed with
are used to make the filter and the other properties with the prefix are used to tweak the result.

My actual question is that if it is safe?. If there can exist a problem in the moment to parse the whole query string in some libraries.

Answer Source

It should be ok. As a matter of fact, ODATA, one of the widely used REST standards in enterprise software uses $ the same way you want to use. Another sensible option you could use is _ (e.g. _sort, _page, etc.)