WT 4 Restfull
Added by Alexandre Bencz over 7 years ago
Hi!
I looked in the version 4 documentation, something about implementing a REST system, but I did not find anything.
I would like to know how I can implement a web service with the basic options of a rest, post, get, delete ... and how to receive the data of the post from the body of the request
I have implemented a webservice ( https://github.com/bencz/CapitalStock/tree/master/src/csWebService ) using the Wt 3, but, all the requests are did send parameters into URL....
Replies (15)
RE: WT 4 Restfull - Added by Roel Standaert over 7 years ago
This is still the same in Wt 4, although we have been looking at improving Wt's support for creating RESTful services, making it less verbose.
You can access the raw data sent by the client with Wt::Http::Request::in().
Regards,
Roel
RE: WT 4 Restfull - Added by Michael Schwarz over 7 years ago
I'm also interested in building a REST webservice with Wt.
So first of all, thank you, Mr. Bencz, for publishing your work, it sure is a great help for getting started!
However, since Roel hinted at some improvements regarding RESTful services, and Mr. Bencz wasn't sure about some implementation details in the first place (see https://redmine.webtoolkit.eu/boards/1/topics/13193), I think it would be very handy to have a "best practice" guide or tutorial for this in the Wt documentation.
I realize that this is not the primary use case for Wt, but when having built a web app with Wt, surely it would be very convenient to write an accompanying webservice using the same technology?
So... is there any chance we'll be seeing such a guide or tutorial in the near future?
RE: WT 4 Restfull - Added by Velvet Jones over 7 years ago
I completely agree!
Wt devs, please give us as much help as you can on creating REST APIs. APIs are not optional for serious applications today, and Wt is a beautifully designed library that we've all chosen as our core technology platform going forward.
I've been a loyal customer for a few years and I've got a very nice user interface based on Wt. I also have an aging API that's written in python and starting to break with newer distributions because... it's python, of course. A new API implementation in a language that's stable (C in this case) is on my todo list, and I'm starting to feel the pressure to get it done.
-
RE: WT 4 Restfull - Added by lm at about 7 years ago
I took a look on the webpage and found a link to this: https://github.com/emweb/wt/blob/master/examples/te-benchmark/benchmark.cpp
It says it illustrates "How to implement a simple RESTful service in Wt using custom WResources." Have you already taken a look at this example?
RE: WT 4 Restfull - Added by Michael Schwarz about 7 years ago
Yup, I've seen that example.
It is indeed a good starting point, but not much more.
With the help of that introduction and the code that Alex Bencz published, I got my own API prototype on the way (although so far it can only fetch data, not send it)... but as Mr Bencz already pointed out, without more "official" documentation, there remains a nagging feeling of "Am I actually doing this right?"...
RE: WT 4 Restfull - Added by Alexandre Bencz about 7 years ago
"there remains a nagging feeling of "Am I actually doing this right?"..."
Exactly!!
look: https://redmine.webtoolkit.eu/boards/1/topics/13193
RE: WT 4 Restfull - Added by lm at about 7 years ago
Yeah, I think you all are right: Wt only has rudimentary support for receiving REST requests, so I think "doing this right" is moot question. If it works and is designed well, it's right.
although so far it can only fetch data, not send it
I think we've been talking about REST services up to now, but sending REST data is the work of a REST client. That is a different matter entirely, though there are some commonalities (sending and receiving JSON being a commonality). I would expect it to be easier to act as a REST client, but we'll see how things turn out.
There appear to be several other libraries for creating REST services and clients if you're not feeling comfortable with Wt. On the other hand, if your work on creating REST services in Wt yields reusable boilerplate, consider contributing?
RE: WT 4 Restfull - Added by Wim Dumon about 7 years ago
Hey,
We have a little layer for easier REST in the making. It's mostly built on top of WResource, and expand the routing to be able to work with parameters/variables in the path. This work is however not yet finished.
Best regards,
Wim.
RE: WT 4 Restfull - Added by Michael Schwarz about 7 years ago
You are right of course, sorry about the confusion about "fetching" and "sending". That was indeed from my test client's point of view. :)
The Wt REST server can deliver requested data but not yet handle data sent to it via PUT or POST.
As to not being comfortable with Wt... that's not really the issue. I love Wt, just not sure if I'm always using it correctly and most efficiently.
And as to building webservices, I know there are various other ways to build them (C not necessarily being the obvious choice g), but I have a lot of existing database code written in C/Qt, and Wt gives me the ability to re-use most of it.
RE: WT 4 Restfull - Added by Velvet Jones over 6 years ago
Hey Wim, how about you guys put the code you're working on (REST API) up somewhere so we can try to contribute?
- Bud
RE: WT 4 Restfull - Added by Alexandre Bencz over 6 years ago
Someone who has implemented a RestFul system with WT, and is willing to put a little guide for us?
RE: WT 4 Restfull - Added by Aaron Wright about 6 years ago
I just started looking into Wt for a RESTful web service. Are there any updates on additional support for it?