I have a running Wt application based on the tutorials all over the web and I was wondering if there is an elegant way of using Wt to add a some Restful API functionality.
I have a few resources I can expose from my current application and I don't want to implement any patches.
If someone has a good idea of how to do that, or even a suggestion of some JSON library that can make the development a breeze, I'd be very thankful.
You should subclass WResource
and implement the WResource::handleRequest
method to provide REST API functionality. Then you should add your resource to your server using WServer::addResource
Also you should ensure that you add your resource to the server before the main Wt appliaction entry point:
Wt::WServer server(argv[0]);
server.setServerConfiguration(argc, argv, WTHTTP_CONFIGURATION);
server.addResource(new MyResource, "/api"));
server.addEntryPoint(Wt::Application, createApplication);