Reputation: 1478
I am trying to do a JSON Restful web service in C/C++. I have tried Axis2/C and Staff, which work great for XML serialization/deserialization but not for JSON.
Upvotes: 34
Views: 67247
Reputation: 824
For web service in C, you can leverage library like ulfius, civetweb:
https://github.com/babelouest/ulfius
https://github.com/civetweb/civetweb/blob/master/docs/Embedding.md
For web service in C++, you can leverage library like libhv, restbed:
https://github.com/ithewei/libhv
https://github.com/Corvusoft/restbed
Upvotes: 1
Reputation: 166
You may want to take a look at webcc.
It's a lightweight C++ HTTP client and server library for embedding purpose based on Boost.Asio (1.66+).
It's quite promising and actively being developed.
It includes a lot of examples to demonstrate how to create a server and client.
Upvotes: 2
Reputation: 698
Take a look at Oat++
It has:
Example endpoint:
ENDPOINT("GET", "users/{name}", getUserByName, PATH(String, name)) {
auto userDto = UserDto::createShared();
userDto->name = name;
return createDtoResponse(Status::CODE_200, userDto);
}
Curl:
$ curl http://localhost:8000/users/john
{"name":"john"}
Upvotes: 3
Reputation: 10422
there are a small number of libraries that support creating rest services with c, e.g. restinio:
#include <restinio/all.hpp>
int main()
{
restinio::run(
restinio::on_this_thread()
.port(8080)
.address("localhost")
.request_handler([](auto req) {
return req->create_response().set_body("Hello, World!").done();
}));
return 0;
}
Upvotes: 9
Reputation: 372
try https://github.com/babelouest/ulfius great library to build C/C++ Restful APIs. can support all platforms: Linux, FreeBSD, Windows and others
Upvotes: 7
Reputation: 1218
For C++ web service, I am using the following stack:
Upvotes: 3
Reputation: 11
There is a JIRA project resolved the support of JSON in AXIS2/C .
I implemented in my project and I managed with the writer (Badgerfish convention) but still I am trying to manage with the reader.
It seems more complicated managing with the stack in the memory.
Upvotes: 1
Reputation: 11833
You might want to take a look at Casablanca introduced in Herb Sutter's blog.
Upvotes: 17