{"id":13514824,"url":"https://github.com/alfanick/rest-cpp","last_synced_at":"2025-03-31T03:31:32.860Z","repository":{"id":13999771,"uuid":"16701046","full_name":"alfanick/rest-cpp","owner":"alfanick","description":"REST-like framework and server for blazing fast web applications in C++11.","archived":false,"fork":false,"pushed_at":"2016-10-23T11:16:39.000Z","size":646,"stargazers_count":16,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-01T18:37:57.615Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://alfanick.github.io/rest-cpp","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/alfanick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-10T16:17:30.000Z","updated_at":"2021-01-13T19:41:02.000Z","dependencies_parsed_at":"2022-09-17T06:50:42.394Z","dependency_job_id":null,"html_url":"https://github.com/alfanick/rest-cpp","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfanick%2Frest-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfanick%2Frest-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfanick%2Frest-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfanick%2Frest-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alfanick","download_url":"https://codeload.github.com/alfanick/rest-cpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246413377,"owners_count":20773053,"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":[],"created_at":"2024-08-01T05:01:02.330Z","updated_at":"2025-03-31T03:31:27.853Z","avatar_url":"https://github.com/alfanick.png","language":"C++","readme":"rest-cpp\n========\nREST-like framework and server for blazing fast web applications in\nC++11.\n\n\nQuick start\n-----------\n``` sh\n$ rest-cpp new blog\n$ cd blog\n$ rest-cpp server\n```\n\nNavigate your browser to http://127.0.0.1:8080 now.\n\n\nBuilding\n--------\nOn OS X Commanand Line Tools are required; on Linux gcc-4.8 or newer is\nrequired. Not tested on other platforms.\n\n\n### Library\nBuild library using `make` on root directory.\n\n### Installation\nRun `make install` on project folder - it will build the library and\ncopy headers, shared library and generator to `/usr/local`.\n\n### Example\nAfter bulding the [Library](#library), go to `example/todo_server` and use `make`. \n\n\nUsage\n-----\nYou may build your own apps from scratch, but you can just `#include \u003crest/rest.h\u003e`\nand use simplified workflow. To make it even easier, you can use `rest-cpp` utility\nto do some work for you.\n\n### rest-cpp utility\n`rest-cpp` allows you to create and manage app.\nIt is installed to `/usr/local/bin` and requires Python in version at\nleast 2.5 (which probably you have already installed).\n\n#### New application\nUse `rest-cpp new [directory]` to create new application. `directory`\nisn't required, app will be created in current directory if omitted.\n\nCreated are two files:\n  - `init.cpp` with basic \"hello world\"\n  - `Makefile` with build commands\n\nExisting files are skipped, to update file to new version, just remove\nprevious one.\n\n##### Makefile\nAvailable tasks:\n  - `make server` - default action, build and start server\n  - `make build` - build server\n\nAvailable options:\n  - `address=ip_or_host` - address for server to bind, default: `0.0.0.0`\n  - `port=number` - port to listen, default: `8080` (ports lower than 1024 may require superuser privileges)\n  - `workers=number` - number of workers, default: `4`\n  - `dispatcher=lc/rr` - workers dispatcher algorithm - `lc` for `LeastConnections`, `rr` for `RoundRobin`, 'uf' for 'Uniform', default: `lc`\n\nTo use options pass them to `make`, i.e. `make server workers=2 port=9000`.\nOptions are complitation-time, not runtime - this means, to i.e. change\nport, you must pass port to make during building process.\n\n*`rest-cpp` wraps make, so you can use `rest-cpp build` and `rest-cpp server` instead of\nmake (you can use the same options as above).*\n\n#### Generators\n`rest-cpp` has builtin generators for resources and services. They work\nassuming you made your app using `rake-cpp new`, that is you use\n`init.cpp` file. Generators must be run in root directory of the\nproject.\n\nResources classes will be stored in `resources` directory, `services`\nfor services. Generators *do not check* if route or other symbol\nalready exists in `init.cpp`. However, they *do not override* service or resource class file.\n\nYou may use both snake_case and CamelCase as names, however, generators\nwill always use snake_case for filenames, simple service names and URIs (unless given) and\nCamelCase as Service and Resource classnames.\n\n##### Inline Service\nInline Service is simple service implemented using C++11 lambda. Use\n`rest-cpp generate inline PATH` to generate one, where `PATH` is URI to\nthe new service.\n\nThe following code will be added to `routes()` in init.cpp:\n\n```cpp\nr-\u003ematch(\"PATH\", [](REST::Service* service) {\n  throw REST::HTTP::NotImplemented();\n});\n```\n\n##### Simple Service\nSimple Service is implemented as function in `init.cpp` file.\nUse `rest-cpp generate simple NAME PATH` to generate one, where `NAME`\nis name of function implementing service and PATH is the URI.\n\nTwo things are added to `init.cpp`:\n\n```cpp\ncreate_service(NAME) {\n  throw REST::HTTP::NotImplemented();\n}\n\n// inside routes()\nr-\u003ematch(\"PATH\", NAME);\n```\n\n###### Simple JSON Service\nThis is variation of simple service with JSON response enabled by\ndefault. Instead of `create_service`, `create_json_service` is used.\n\n##### Service\nGenerates full featured Service class - use `rest-cpp generate service NAME [PATH]`.\nYou may do anything you want in Service - every HTTP method is allowed.\n`PATH` is optional, URI is matched to snakecased `NAME` unless given.\n\nService class is generated in `services/NAME.cpp` as follows:\n\n```cpp\n#include \u003crest/service.h\u003e\n\nclass NAME : public REST::Service {\n  void method(REST::Request::Method type) {\n    throw REST::HTTP::NotImplemented();\n  }\n};\n```\n\nFollowing route is added to `init.cpp`:\n\n```cpp\n// inside routes()\nr-\u003emount\u003cNAME\u003e(\"PATH\");\n```\n\n##### Resource\nResource represents RESTable resource. HTTP methods are mapped to CRUD\nactions as follows:\n  - `POST - create()`\n  - `GET - read()`\n  - `PATCH or PUT - update()`\n  - `DELETE - destroy()`\n\nResource is specialization of Service, you may override `method()` to\nhandle other HTTP method (if you like to break REST pattern).\n\nGenerator creates `resources/NAME.cpp` file:\n\n```cpp\n#include \u003crest/resource.h\u003e\n\nclass NAME : public REST::Resource {\n  void read() {\n    throw REST::HTTP::NotImplemented();\n  }\n};\n```\n\nResources may be singular or plural, depending on route generated.\nSingular resource match exact URI, plural resource match URI with\noptional splat.\n\n###### Singular resource\nUse \u003ccode\u003erest-cpp generate \u003cb\u003eresource\u003c/b\u003e NAME [PATH]\u003c/code\u003e to generate singular\nresource. `PATH` is optional, URI is matched to snakecased `NAME` unless\ngiven.\n\n```cpp\n// inside routes()\nr-\u003eresource\u003cNAME\u003e(\"PATH\");\n\n// unless PATH given\nr-\u003eresource\u003cNAME\u003e();\n```\n\n###### Plular resource\nUse \u003ccode\u003erest-cpp generate \u003cb\u003eresources\u003c/b\u003e NAME [PATH]\u003c/code\u003e to generate plular\nresource. `PATH` is optional, URI is matched to snakecased `NAME` if not\ngiven.\n\n```cpp\n// inside rotues()\nr-\u003eresources\u003cNAME\u003e(\"PATH\");\n\n// unless PATH given\nr-\u003eresources\u003cNAME\u003e();\n```\n\n\nExample\n-------\nlorem ipsum\n\n\nBasis of operation\n------------------\nlorem ipsum\n\n\nAuthors\n-------\n- Amadeusz Juskowiak - amadeusz[at]me.com\n\n### Contributors\n- Błażej Kotowski - kotowski.blazej[at]gmail.com\n\nMade with love, inspired by put.poznan.pl\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfanick%2Frest-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falfanick%2Frest-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfanick%2Frest-cpp/lists"}