{"id":13418567,"url":"https://github.com/meltwater/served","last_synced_at":"2025-03-15T03:31:31.220Z","repository":{"id":21678538,"uuid":"24999722","full_name":"meltwater/served","owner":"meltwater","description":"A C++11 RESTful web server library","archived":true,"fork":false,"pushed_at":"2021-01-17T15:05:38.000Z","size":811,"stargazers_count":710,"open_issues_count":26,"forks_count":175,"subscribers_count":70,"default_branch":"master","last_synced_at":"2024-08-05T02:01:19.116Z","etag":null,"topics":["data-platform","datasift"],"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/meltwater.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}},"created_at":"2014-10-09T17:08:24.000Z","updated_at":"2024-06-29T05:11:26.000Z","dependencies_parsed_at":"2022-08-27T17:00:52.291Z","dependency_job_id":null,"html_url":"https://github.com/meltwater/served","commit_stats":null,"previous_names":["datasift/served"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meltwater%2Fserved","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meltwater%2Fserved/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meltwater%2Fserved/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meltwater%2Fserved/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meltwater","download_url":"https://codeload.github.com/meltwater/served/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243495503,"owners_count":20299922,"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":["data-platform","datasift"],"created_at":"2024-07-30T22:01:03.858Z","updated_at":"2025-03-15T03:31:28.839Z","avatar_url":"https://github.com/meltwater.png","language":"C++","funding_links":[],"categories":["TODO scan for Android support in followings"],"sub_categories":[],"readme":"Served\n======\n\n![Served Logo](served-logo.png)\n\n[![Build Status](https://travis-ci.org/bowlofstew/served.png)](https://travis-ci.org/bowlofstew/served)\n\n## Overview\n\nServed is a C++ library for building high performance RESTful web servers.\n\nServed builds upon [Boost.ASIO](http://www.boost.org/) to provide a simple API for developers to create HTTP services in C++.\n\nFeatures:\n* [x] HTTP 1.1 compatible request parser\n* [x] Middleware / plug-ins\n* [x] Flexible handler API\n* [x] Cross-platform compatible\n\n## Installation\n\n### Requirements\n\n* [Required] - [Boost (1.53 or newer)](http://www.boost.org/)\n* [Optional] - [Ragel](http://www.complang.org/ragel/)\n\n### Building\n\n```bash\n$ git clone git@github.com:meltwater/served.git\n$ mkdir served.build \u0026\u0026 cd served.build\n$ cmake ../served \u0026\u0026 make\n```\n\nOr, using [bazel](https://bazel.build/):\n\n```bash\n$ git clone git@github.com:meltwater/served.git\n$ cd served\n$ bazel build :served\n$ bazel test :served-test\n```\n\n### Getting Started\n\nThe most basic example of creating a server and handling a `HTTP GET` for the path `/hello`:\n```cpp\n#include \u003cserved/served.hpp\u003e\n\nint main(int argc, char const* argv[]) {\n\t// Create a multiplexer for handling requests\n\tserved::multiplexer mux;\n\n\t// GET /hello\n\tmux.handle(\"/hello\")\n\t\t.get([](served::response \u0026 res, const served::request \u0026 req) {\n\t\t\tres \u003c\u003c \"Hello world!\";\n\t\t});\n\n\t// Create the server and run with 10 handler threads.\n\tserved::net::server server(\"127.0.0.1\", \"8080\", mux);\n\tserver.run(10);\n\n\treturn (EXIT_SUCCESS);\n}\n```\n\nTo test the above example, you could run the following command from a terminal:\n```bash\n$ curl http://localhost:8080/hello -ivh\n```\n\nYou can also use named path variables for REST parameters:\n```cpp\nmux.handle(\"/users/{id}\")\n\t.get([](served::response \u0026 res, const served::request \u0026 req) {\n\t\tres \u003c\u003c \"User: \" \u003c\u003c req.params[\"id\"];\n\t});\n```\n\nTo test the above example, you could run the following command from a terminal:\n```bash\n$ curl http://localhost:8080/users/dave -ivh\n```\n\nIf you need to be more specific, you can specify a pattern to use to validate\nthe parameter:\n```cpp\nmux.handle(\"/users/{id:\\\\d+}\")\n\t.get([](served::response \u0026 res, const served::request \u0026 req) {\n\t\tres \u003c\u003c \"id: \" \u003c\u003c req.params[\"id\"];\n\t});\n```\n\nTo test the above example, you could run the following command from a terminal:\n```bash\n$ curl http://localhost:8080/users/1 -ivh\n```\n\nMethod handlers can have arbitrary complexity:\n```cpp\nmux.handle(\"/users/{id:\\\\d+}/{property}/{value:[a-zA-Z]+\")\n\t.get([](served::response \u0026 res, const served::request \u0026 req) {\n\t\t// handler logic\n\t});\n```\n\nIf you want to automatically log requests, you could use a plugin (or make your\nown):\n```cpp\n#include \u003cserved/plugins.hpp\u003e\n// ...\nmux.use_after(served::plugin::access_log);\n```\n\nYou can also access the other elements of the request, including headers and\ncomponents of the URI:\n```cpp\nmux.handle(\"/posts/{id:\\\\d+}\")\n\t.post([](served::response \u0026 res, const served::request \u0026 req) {\n\t\tif (req.header(\"Content-Type\") != \"application/json\") {\n\t\t\tserved::response::stock_reply(400, res);\n\t\t\treturn;\n\t\t}\n\t\tres \u003c\u003c req.url().fragment();\n\t});\n```\n\n### Compile Options\n\nOption                 | Purpose\n---------------------- | -----------------------------------\nSERVED_BUILD_SHARED    | Build shared library\nSERVED_BUILD_STATIC    | Build static library\nSERVED_BUILD_TESTS     | Build unit test suite\nSERVED_BUILD_EXAMPLES  | Build bundled examples\nSERVED_BUILD_DEB       | Build DEB package (note: you must also have dpkg installed)\nSERVED_BUILD_RPM       | Build RPM package (note: you must also have rpmbuild installed)\n\n## System Compatibility\n\nOS           | Compiler      | Status\n------------ | ------------- | -------------\nLinux        | GCC 4.8       | Working\nOSX          | Clang 3.5     | Working\n\n## TODO\n\n- Chunked encoding support\n\n## Contributing\n\nPull requests are welcome.\n\n## Authors\n\n* [@cjgdev](https://github.com/cjgdev)\n* [@Jeffail](https://github.com/Jeffail)\n\n## Copyright\n\nSee [LICENSE.md](LICENSE.md) document\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeltwater%2Fserved","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeltwater%2Fserved","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeltwater%2Fserved/lists"}