Answer the question
In order to leave comments, you need to log in
On what and how to write web service rest api, if the logic is written in C ++?
There is software written in C++ that performs some useful work, and whose capabilities I would like to use in some other programs of the complex. I was asked to write a web service rest api. Since I have never come across this beast, I read the Internet, but still there are many questions, please help with advice:
1) I understand correctly that in order to talk about any web service api, my application must be essentially a web -server?
2) Is it logical to write such things in C ++ (Qt), the load promises to be not very large? My opinion, not the most competent, is not very logical. How to pair in this case? What is the best way to write?
3) Found some C++ solutions ( en.wikipedia.org/wiki/List_of_web_service_frameworks). Found
C++ REST SDK (codename "Casablanca") should I use it?
4) If you still write in C ++ (Qt), maybe someone will throw a simple, but indicative example, I will be very grateful.
Answer the question
In order to leave comments, you need to log in
PHP uses C syntax. Java hasn't gone too far in deviance either. But no one bothers to build a cgi-application from your logic and use it in a web server.
Yes, you understand correctly that all web services are primarily a web server.
You can take node.js, for which the rest of the frameworks are overabundant, and connect it with an existing c++ project using the node-ffi module. The module allows you to work with dll node-ffi from JS code
1) IMHO it is necessary to proceed from how it will be easier to connect the http-server and your already written software. It is not at all clear from the question what it is.
2) Rest api is essentially just a url format - it doesn’t matter what it is written on, and it’s worth writing on that (and taking into account 1) what you know better. If, apart from c++ with qt, you don’t really understand anything, write in c++ with qt. (here, in principle, a ready-made http server on qt https://github.com/vinipsmaker/tufao (the first thing that came across in Google, there are some examples there)
3) http servers in different languages and technologies are dark - but again it is worth using something that is easier and more familiar with, but do not forget about 1 point.
you can spend a couple of evenings learning Python, it has good integration with C.
But python will often help you out in the future. I am now writing similar web services in python + flask. the code turns out to be MEGA compact. but the truth is I use html for the service and on the client side I parse it with an xml parser.
For the rest, you can use the ready parquet flask-jsonrpc
Alternatively, a REST service can be written in java, the simplest framework (in my opinion) jersey . From java you can work with your c++ code using JNI
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question