I'm starting with the onion library and trying to create a HTTP server that will send me the html files located in the directory "pages", and also be a REST server for all URL starting with "config/".
Looking at the examples, I was able to create a small REST server like this: onion_url *urls=onion_root_url(o);
onion_url_add_static(urls, "config/version", "0.0.1\r\n", HTTP_OK);
onion_url_add(urls, "config/hello", hello);
I can also be a simple webserver for all my html files located in "pages": onion_handler *dir=onion_handler_export_local_new("pages");
onion_handler_add(dir, onion_handler_static("<h1>404 - File not found.</h1>", 404) );
Now I don't know how to combine both. I mean, I want to get pages/index.html if I request http://myhost/index.html
, and I want to get "0.0.1" when I request http://myhost/config/version
Maybe I have to create a root handler and then redirect the requests? I feel like I'm missing something very basic with the onion... Could someone here help me and provide me some code?