Closed alexe100 closed 5 years ago
Not tested, but you should be able to use:
onion_url_add(urls, "^/([1-9]+)/([1-9]+)/$", handle);
...
month = onion_request_get_query(req, "1");
year = onion_request_get_query(req, "2");
Truth be told its long time I dont use this functionality, so there may be a better way.
About the difference is to add the data parameter to the handler, or not. Remember the handler has the signature:
onion_connection_status_t my_handler(void *userdata, onion_request *, onion_response *);
So if you use the _with_data
, then the userdata
is passed through. But sometimes you don't need any data to pass.
Hi! I am trying to implement a response for a GET action for https://www.xxx.yyy/storeddata/11/2018
I am using: onion_url_add(urls,"^(.*)$", HandleReq);
Then I have to get fullpath and do string tokenizer in order to verify if the month and year were passed. Using C# it is possible to define a pattern like:
.../{$month}/{$year} and get we just process month and year variables. Can we do something like that using onion?
By the way, another curiosity I have:
onion_url_add vs onion_url_add_with_data
Which data is that? HTTP body? I use onion_request_get_data(req);
Thanks a lot
Alex