Project

General

Profile

REST API using WT

Added by Naveen A.N about 12 years ago

My application has two parts one is UI and the other is API so i am planning to use WT for both.

I came to know that i can use the custom handle request and display the XML or JSON from this example.

https://github.com/kdeforche/wt/blob/master/examples/blog/BlogRSSFeed.C

I need to upload XML documents using CURL is it possible?


Replies (3)

RE: REST API using WT - Added by Wim Dumon about 12 years ago

Hi Naveen,

You want to send files to the Wt application? The WFileUpload widget uses a WFileResource internally - you can probably use that as a starting point. Look at src/Wt/WFileUpload.C.

Or do you need to send files from the server by invoking CURL? You can call curl, of course, as a separate command through system(), or linked in as a library. You can also use Wt's http client classes, but afaik there's no out of the box support there for sending files.

BR,

Wim.

RE: REST API using WT - Added by Naveen A.N about 12 years ago

Hello Wim,

I need to receive the data from the CURL like curl -X POST -H 'content-type: application/xml' 'http://localhost:8080/update' -d '<docs>
     <doc>
          <field name="test">http://www.google.com</field>
          <field name="test1">http://www.webtoolkit.eu/</field>
     </doc>
</docs>'

Can i receive the data using the http client class ??

RE: REST API using WT - Added by Wim Dumon about 12 years ago

Not with the client http classes, but you can simply use a WResource that is deployed on a fixed URL. See WServer::addResource().

BR,

Wim.

    (1-3/3)