There are two kinds of paramters we may get from any request:
- normal parameters, taken from the URL/headers of the request
- JSON parameters, taken inside the body of the request
The first kind is the most tipical.
They require an explicit declaration before the request kicks in, for which we created the method add_endpoint_parameter
.
Without the declaration, they won't be parsable even if the client sends them.
They should be preferred to JSON parameters.
The second category is the most elastic. They are JSON data which does not have limits in size and are better encoded. They can be as many as the user wants and we don't have to declare which one we receive on server side.
I parse the two kinds when calling the internal get_input
method.
To avoid collisions the first parameters are preferred,
if using the same names on both parameters we label with '_json' the key.
Examples, based on the endpoint above:
http GET $SERVER/api/test?test=1
http GET $SERVER/api/test test=2
http GET $SERVER/api/test?test=1 test=2
http GET $SERVER/api/test?anothername=1 anothername=2
Final note: the most important and most used method - the GET method - should not be using the JSON parameters from REST specifications, because it should not need the body to be received to fullfil the request. They do work in our prototype but the web discourages it. It's up to us I guess.