{"id":19002283,"url":"https://github.com/tudororban/groth","last_synced_at":"2025-06-25T02:04:31.635Z","repository":{"id":223340853,"uuid":"754840291","full_name":"TudorOrban/Groth","owner":"TudorOrban","description":"A mini-library for building REST API's in C++","archived":false,"fork":false,"pushed_at":"2024-02-19T15:45:43.000Z","size":375,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-21T13:43:21.564Z","etag":null,"topics":["cpp","dynamic-routing","rest-api","web-server"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TudorOrban.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2024-02-08T21:30:54.000Z","updated_at":"2024-02-19T16:48:02.000Z","dependencies_parsed_at":"2024-02-19T19:24:17.132Z","dependency_job_id":"1698f281-0d03-459b-880e-37ae668030f0","html_url":"https://github.com/TudorOrban/Groth","commit_stats":null,"previous_names":["tudororban/groth"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TudorOrban/Groth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TudorOrban%2FGroth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TudorOrban%2FGroth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TudorOrban%2FGroth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TudorOrban%2FGroth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TudorOrban","download_url":"https://codeload.github.com/TudorOrban/Groth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TudorOrban%2FGroth/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261789229,"owners_count":23209774,"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":["cpp","dynamic-routing","rest-api","web-server"],"created_at":"2024-11-08T18:14:32.011Z","updated_at":"2025-06-25T02:04:31.608Z","avatar_url":"https://github.com/TudorOrban.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"Groth is a mini-library for building REST API's in C++, currently available only for Windows servers. It employs a thread pool for efficiently handling concurrent requests, and supports dynamic route parameters with limited type checking.\n\n### Usage\nGroth is not yet packaged as a library, but you can use it by following these steps:\n1. Ensure you have a C++ compiler that supports the C++ 17 standard and CMake installed.\n2. Fetch the repository into your project's directory and link it by adding a line in the root CMakeLists such as:\n```\nadd_subdirectory(examples/SimpleServer)\n```\n3. Create a WebApplication as shown in the [examples](https://github.com/TudorOrban/Groth/tree/main/examples/SimpleServer), specifying the port:\n```c++\n#include \"WebApplication.h\"\n\nint main() {\n    WebApplication app(8080);\n}\n```\n4. To add routes, create a Controller that extends BaseController:\n```c++\n// MyController.h\nclass MyController : public BaseController {\npublic:\n    MyController() {\n        std::cout \u003c\u003c \"Controller instantiated\" \u003c\u003c std::endl;\n    }\n    void registerRoutes(RouteConfig\u0026 routeConfig) override;\n};\n```\nand configure your routes like this:\n```c++\n// MyController.cpp\nvoid MyController::registerRoutes(RouteConfig\u0026 routeConfig) {\n    std::cout \u003c\u003c \"Registering routes in MyController\" \u003c\u003c std::endl;\n    routeConfig.addRoute(\"GET\", \"/users\", [](const HttpRequest\u0026 req, const RouteParameters\u0026 params) -\u003e HttpResponse {\n        HttpResponse res;\n        res.setStatusCode(200);\n        res.setHeader(\"Content-Type\", \"text/html\");\n        res.setBody(\"\u003chtml\u003e\u003cbody\u003e\u003ch1\u003eWelcome to MyController!\u003c/h1\u003e\u003c/body\u003e\u003c/html\u003e\");\n        return res;\n    });\n}\n```\n5. Register your controller and run the server:\n```c++\n#include \"WebApplication.h\"\n#include \"MyController.h\"\n\nint main() {\n    WebApplication app(8080);\n    app.addController\u003cMyController\u003e();\n    app.run();\n    return 0;\n}\n```\n6. Finally, create a build folder in the root of Groth and run from there: `cmake ..`, `cmake --build . --config Release`. Then go to `build\\YourProject\\Release` and run `.\\YourProject.exe`.\n\n### Performance\nA performance test has been run with [Apache JMeter](https://jmeter.apache.org/) on an AMD Ryzen 5 4600H with 16GB of memory. The results are available [here](https://github.com/TudorOrban/Groth/tree/main/tests/JMeter). The thread group made 50000 concurrent calls to a dynamic route that returns a simple HTML with the received parameter. The aggregate report:\n\n![Aggregate](tests/JMeter/aggregate.csv \"Aggregate report\")\n\nshows a good overall performance (124ms), with 50% of the requests being handled under 20ms, and and average of 1000 requests handled per second. On the other hand, the 99% percentile suggests a long-tail problem, partially attributed to the server cold start (see [response time graph](https://github.com/TudorOrban/Groth/blob/main/tests/JMeter/screenshots/GrothResponseTimeGraph.png)), and the high error rate is indicative of some underlying issues that will soon be addressed. See the [graph results](https://github.com/TudorOrban/Groth/blob/main/tests/JMeter/screenshots/GrothGraphResults.png) as well.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftudororban%2Fgroth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftudororban%2Fgroth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftudororban%2Fgroth/lists"}