{"id":16690991,"url":"https://github.com/venediktov/crud","last_synced_at":"2025-03-21T18:33:42.520Z","repository":{"id":91756961,"uuid":"43480049","full_name":"venediktov/CRUD","owner":"venediktov","description":"Restful web-service library written in C++11  based on Boost.ASIO and CRUD handlers","archived":false,"fork":false,"pushed_at":"2024-02-15T13:12:56.000Z","size":64,"stargazers_count":33,"open_issues_count":6,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-18T04:11:22.509Z","etag":null,"topics":["asio","asynchronous","boost","boost-asio","boost-beast","boost-library","cpp11","cpp14","cpp17","crud","crud-api","crud-operation","handlers","lightweight","performance","restful","restful-webservices","web-api","web-service"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/venediktov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-01T05:30:58.000Z","updated_at":"2024-11-07T06:44:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"e1c0b690-249b-438f-abd2-b6ab85e54907","html_url":"https://github.com/venediktov/CRUD","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venediktov%2FCRUD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venediktov%2FCRUD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venediktov%2FCRUD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/venediktov%2FCRUD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/venediktov","download_url":"https://codeload.github.com/venediktov/CRUD/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244849804,"owners_count":20520791,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asio","asynchronous","boost","boost-asio","boost-beast","boost-library","cpp11","cpp14","cpp17","crud","crud-api","crud-operation","handlers","lightweight","performance","restful","restful-webservices","web-api","web-service"],"created_at":"2024-10-12T16:06:25.527Z","updated_at":"2025-03-21T18:33:42.441Z","avatar_url":"https://github.com/venediktov.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CRUD\nHigh performance Restful web-service library written in C++11  based on boost.ASIO and CRUD handlers\n\nThis library supports persistent connections to achieve highest throughput and utilizes optinally regex for enpoints\n\n[![build ](https://travis-ci.org/venediktov/CRUD.svg?branch=master)](https://travis-ci.org/venediktov/CRUD)\n\n### Installing from GitHub\n```bash\ngit clone https://github.com/venediktov/CRUD.git\n```\n\n### Building on Linux \n```bash\n$ mkdir Release\n$ cd Release\n$ cmake -DCMAKE_BUILD_TYPE=Release -DCRUD_WITH_EXAMPLES=1 .. -G \"Unix Makefiles\"\n$ make -j $(nproc) install\n\n```\n\n### Building on  Mac OS \n```bash\n$ mkdir Release\n$ cd Release\n$ cmake -DCMAKE_BUILD_TYPE=Release -DCRUD_WITH_EXAMPLES=1 .. -G \"Unix Makefiles\"\n$ make -j $(sysctl -n hw.physicalcpu) install\n\n```\n\n\n\n### Running examples \n```bash\n$ cd Release/examples\n$ ./webserver 0.0.0.0 8080 . \u0026 \n$ ./simple_restful_service 0.0.0.0 8081 . \u0026 \n$ ./regex_restful_service 0.0.0.0 8082 . \u0026 \n$ ./persisted_regex_restful_service 0.0.0.0 8083 . \u0026\n\n```\n\n\n### Testing output and benchmarks\n```bash\ncurl localhost:8080\ncurl localhost:8081/venue_handler/RTB\ncurl localhost:8082/venue_handler/ANY/123\ncurl localhost:8083/venue_handler/ANY/123\nab -k -n 100000 -c 30 http://localhost:8081/RTB\nab -k -n 100000 -c 30 http://localhost:8082/ANY/123\nab -k -n 100000 -c 30 http://localhost:8083/ANY/123\n\n```\n\n### Stop all background examples\n```bash\npkill -9 \"persisted|restful|webserver\"\n```\n\n\n## Utilizing API\n\n### REST handler with regex\n\n```C++\n    using regex_restful_dispatcher_t =  http::crud::crud_dispatcher\u003chttp::server::request, http::server::reply\u003e;\n    regex_restful_dispatcher_t regex_handler(\".\") ; //root is irrelavant for REST only used for web-server\n    regex_handler.crud_match(boost::regex(\"/venue_handler/(\\w+)\") )\n                 .post([](http::server::reply \u0026 r, const http::crud::crud_match\u003cboost::cmatch\u003e \u0026 match) {\n                    r \u003c\u003c \"{}\" \u003c\u003c http::server::reply::flush(\"json\") ;\n                    std::cout \u003c\u003c \"POST group_1_match=[ \u003c\u003c match[1] \u003c\u003c \"], request_data=\" \u003c\u003c match.data \u003c\u003c std::endl;\n                 });\n```\n\n### simple REST handler\n\n```C++\n   // SIMPLE NO REGEX MATCH FOR POST \"/venue_handler/RTB\"\n    using simple_restful_dispatcher_t = http::crud::crud_dispatcher\u003chttp::server::request, http::server::reply, std::string, std::string\u003e;\n    simple_restful_dispatcher_t simple_handler(\".\") ; //root is irrelavant for REST only used for web-server\n    simple_handler.crud_match(std::string(\"/venue_handler/RTB\") )\n                  .post([](http::server::reply \u0026 r, const http::crud::crud_match\u003cstd::string\u003e \u0026 match) {\n                     r \u003c\u003c \"{}\" \u003c\u003c http::server::reply::flush(\"json\") ;\n                     std::cout \u003c\u003c \"POST request_data=\" \u003c\u003c match.data \u003c\u003c std::endl;\n                   });\n```\n### All in one go\n```C++\n    // CREAT/READ/UPDATE/DELETE \"/venue_handler/XEMDP/123\"\n    handler.crud_match(boost::regex(\"/venue_handler/(\\\\w+)/(\\\\d+)\") )\n           .put([](http::server::reply \u0026 r, const http::crud::crud_match\u003cboost::cmatch\u003e \u0026 match)\n              std::cout \u003c\u003c \"CREATE request=\" \u003c\u003c match[0] \u003c\u003c \"/\" \u003c\u003c match[1] \u003c\u003c std::endl;\n              r = http::server::reply::stock_reply(http::server::reply::no_content);\n           })\n           .get([](http::server::reply \u0026 r, const http::crud::crud_match\u003cboost::cmatch\u003e \u0026 match) {\n              r \u003c\u003c \"name: \" \u003c\u003c match[1] \u003c\u003c \", instance number: \" \u003c\u003c match[2]\n                \u003c\u003c http::server::reply::flush(\"text\") ;\n              std::cout \u003c\u003c \"READ request=\" \u003c\u003c match[0] \u003c\u003c std::endl;\n           })\n           .post([](http::server::reply \u0026 r, const http::crud::crud_match\u003cboost::cmatch\u003e  \u0026 match) {\n              r \u003c\u003c \"name: \" \u003c\u003c match[1] \u003c\u003c \", instance number: \" \u003c\u003c match[2]\n                \u003c\u003c http::server::reply::flush(\"text\") ;\n              std::cout \u003c\u003c \"UPDATE request=\" \u003c\u003c match[0] \u003c\u003c std::endl;\n              std::cout \u003c\u003c \"UPDATE request_data=\" \u003c\u003c match.data \u003c\u003c std::endl;\n           })\n           .del([](http::server::reply \u0026 r, const http::crud::crud_match\u003cboost::cmatch\u003e \u0026 match)\n              std::cout \u003c\u003c \"DELETE request=\" \u003c\u003c match[0] \u003c\u003c \"/\" \u003c\u003c match[1] \u003c\u003c std::endl;\n              r = http::server::reply::stock_reply(http::server::reply::no_content);\n           }) ;\n```\n\n### Setting up connection types\n\n#### For keep-alive persistent connections specifiy second template argument with presistent type for connection\n```C++\nhttp::server::server\u003csimple_restful_dispatcher_t, http::server::persistent_connection\u003e server{host,port,handler};\n```\n\n#### By default server is using non-persistent connection from the library \n```C++\nhttp::server::server\u003csimple_restful_dispatcher_t\u003e server{host,port,handler};\n```\n\n#### Adding CRUD as GitHub submodule to your project\nCreate a file .gitmodules in the root of your project with contents\n```bash\n[submodule \"CRUD\"]\n\tpath = CRUD\n\turl = https://github.com/venediktov/CRUD.git\n```\n\nOr execute following command in your repo\n```bash\ngit submodule add https://github.com/venediktov/CRUD\n```\n\nIf you add CRUD as submodule you will have to use ```git clone --recursive``` for your repo in order to get us as dependency\n\nYou can look at GitHub subtrees instead ```git subtree add --prefix CRUD git@github.com:venediktov/CRUD.git master --squash```\n\n## Support on Beerpay\nHey dude! Help me out for a couple of :beers:!\n\n[![Beerpay](https://beerpay.io/venediktov/CRUD/badge.svg?style=beer-square)](https://beerpay.io/venediktov/CRUD)  [![Beerpay](https://beerpay.io/venediktov/CRUD/make-wish.svg?style=flat-square)](https://beerpay.io/venediktov/CRUD?focus=wish)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvenediktov%2Fcrud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvenediktov%2Fcrud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvenediktov%2Fcrud/lists"}