Crud

Restful web-service library written in C++11 based on Boost.ASIO and CRUD handlers
Alternatives To Crud
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Php Curl Class3,1526903522 days ago66September 24, 20223unlicensePHP
PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs
Rest Client1,446
4 years ago32apache-2.0Java
Tool to test HTTP/RESTful webservices.
Restclient1,110
111 days ago31December 28, 202124mitC#
🦄 A Promise based REST and HTTP client for Unity 🎮
Ulfius932
14 days ago9lgpl-2.1C
Web Framework to build REST APIs, Webservices or any HTTP endpoint in C language. Can stream large amount of data, integrate JSON data with Jansson, and create websocket services
Horse897
8 days ago10mitPascal
Fast, opinionated, minimalist web framework for Delphi
Just Api791
1a year ago21August 24, 201915mitJavaScript
:boom: Test REST, GraphQL APIs
Restheart761213 days ago52June 29, 20221agpl-3.0Java
REST, GraphQL and WebSocket APIs for MongoDB.
Ngrest398
a year ago10apache-2.0C++
Fast and easy C++ RESTful WebServices framework
Cppwebframework326
3 years agomitC++
​The C++ Web Framework (CWF) is a MVC web framework, Open Source, under MIT License, using C++ with Qt to be used in the development of web applications.
Kilo319118 days ago91April 02, 20224apache-2.0Java
Lightweight REST for Java
Alternatives To Crud
Select To Compare


Alternative Project Comparisons
Readme

CRUD

High performance Restful web-service library written in C++11 based on boost.ASIO and CRUD handlers

This library supports persistent connections to achieve highest throughput and utilizes optinally regex for enpoints

build

Installing from GitHub

git clone https://github.com/venediktov/CRUD.git

Building on Linux

$ mkdir Release
$ cd Release
$ cmake -DCMAKE_BUILD_TYPE=Release -DCRUD_WITH_EXAMPLES=1 .. -G "Unix Makefiles"
$ make -j $(nproc) install

Building on Mac OS

$ mkdir Release
$ cd Release
$ cmake -DCMAKE_BUILD_TYPE=Release -DCRUD_WITH_EXAMPLES=1 .. -G "Unix Makefiles"
$ make -j $(sysctl -n hw.physicalcpu) install

Running examples

$ cd Release/examples
$ ./webserver 0.0.0.0 8080 . & 
$ ./simple_restful_service 0.0.0.0 8081 . & 
$ ./regex_restful_service 0.0.0.0 8082 . & 
$ ./persisted_regex_restful_service 0.0.0.0 8083 . &

Testing output and benchmarks

curl localhost:8080
curl localhost:8081/venue_handler/RTB
curl localhost:8082/venue_handler/ANY/123
curl localhost:8083/venue_handler/ANY/123
ab -k -n 100000 -c 30 http://localhost:8081/RTB
ab -k -n 100000 -c 30 http://localhost:8082/ANY/123
ab -k -n 100000 -c 30 http://localhost:8083/ANY/123

Stop all background examples

pkill -9 "persisted|restful|webserver"

Utilizing API

REST handler with regex

    using regex_restful_dispatcher_t =  http::crud::crud_dispatcher<http::server::request, http::server::reply>;
    regex_restful_dispatcher_t regex_handler(".") ; //root is irrelavant for REST only used for web-server
    regex_handler.crud_match(boost::regex("/venue_handler/(\w+)") )
                 .post([](http::server::reply & r, const http::crud::crud_match<boost::cmatch> & match) {
                    r << "{}" << http::server::reply::flush("json") ;
                    std::cout << "POST group_1_match=[ << match[1] << "], request_data=" << match.data << std::endl;
                 });

simple REST handler

   // SIMPLE NO REGEX MATCH FOR POST "/venue_handler/RTB"
    using simple_restful_dispatcher_t = http::crud::crud_dispatcher<http::server::request, http::server::reply, std::string, std::string>;
    simple_restful_dispatcher_t simple_handler(".") ; //root is irrelavant for REST only used for web-server
    simple_handler.crud_match(std::string("/venue_handler/RTB") )
                  .post([](http::server::reply & r, const http::crud::crud_match<std::string> & match) {
                     r << "{}" << http::server::reply::flush("json") ;
                     std::cout << "POST request_data=" << match.data << std::endl;
                   });

All in one go

    // CREAT/READ/UPDATE/DELETE "/venue_handler/XEMDP/123"
    handler.crud_match(boost::regex("/venue_handler/(\\w+)/(\\d+)") )
           .put([](http::server::reply & r, const http::crud::crud_match<boost::cmatch> & match)
              std::cout << "CREATE request=" << match[0] << "/" << match[1] << std::endl;
              r = http::server::reply::stock_reply(http::server::reply::no_content);
           })
           .get([](http::server::reply & r, const http::crud::crud_match<boost::cmatch> & match) {
              r << "name: " << match[1] << ", instance number: " << match[2]
                << http::server::reply::flush("text") ;
              std::cout << "READ request=" << match[0] << std::endl;
           })
           .post([](http::server::reply & r, const http::crud::crud_match<boost::cmatch>  & match) {
              r << "name: " << match[1] << ", instance number: " << match[2]
                << http::server::reply::flush("text") ;
              std::cout << "UPDATE request=" << match[0] << std::endl;
              std::cout << "UPDATE request_data=" << match.data << std::endl;
           })
           .del([](http::server::reply & r, const http::crud::crud_match<boost::cmatch> & match)
              std::cout << "DELETE request=" << match[0] << "/" << match[1] << std::endl;
              r = http::server::reply::stock_reply(http::server::reply::no_content);
           }) ;

Setting up connection types

For keep-alive persistent connections specifiy second template argument with presistent type for connection

http::server::server<simple_restful_dispatcher_t, http::server::persistent_connection> server{host,port,handler};

By default server is using non-persistent connection from the library

http::server::server<simple_restful_dispatcher_t> server{host,port,handler};

Adding CRUD as GitHub submodule to your project

Create a file .gitmodules in the root of your project with contents

[submodule "CRUD"]
	path = CRUD
	url = https://github.com/venediktov/CRUD.git

Or execute following command in your repo

git submodule add https://github.com/venediktov/CRUD

If you add CRUD as submodule you will have to use git clone --recursive for your repo in order to get us as dependency

You can look at GitHub subtrees instead git subtree add --prefix CRUD [email protected]:venediktov/CRUD.git master --squash

Support on Beerpay

Hey dude! Help me out for a couple of 🍻!

Beerpay Beerpay

Popular Webservices Projects
Popular Rest Projects
Popular Application Programming Interfaces Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
C Plus Plus
Cpp17
Cpp11
Cpp14
Restful
Performance
Regex
Boost
Webapi
Webservice
Asio