{"id":15136944,"url":"https://github.com/includeos/mana","last_synced_at":"2025-10-08T08:43:57.581Z","repository":{"id":77440899,"uuid":"69335191","full_name":"includeos/mana","owner":"includeos","description":"IncludeOS C++ Web Application Framework","archived":false,"fork":false,"pushed_at":"2019-03-27T13:32:30.000Z","size":926,"stargazers_count":71,"open_issues_count":0,"forks_count":10,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-06T17:04:43.368Z","etag":null,"topics":["conan"],"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/includeos.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":"2016-09-27T08:24:01.000Z","updated_at":"2024-08-12T19:25:09.000Z","dependencies_parsed_at":"2023-06-15T18:30:22.513Z","dependency_job_id":null,"html_url":"https://github.com/includeos/mana","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/includeos/mana","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/includeos%2Fmana","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/includeos%2Fmana/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/includeos%2Fmana/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/includeos%2Fmana/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/includeos","download_url":"https://codeload.github.com/includeos/mana/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/includeos%2Fmana/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278916444,"owners_count":26068090,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["conan"],"created_at":"2024-09-26T06:42:02.003Z","updated_at":"2025-10-08T08:43:57.563Z","avatar_url":"https://github.com/includeos.png","language":"C++","readme":"# mana\nIncludeOS C++ Web Application Framework\n\n[Acorn](../../examples/acorn) is a web server built with Mana which demonstrates a lot of its potential.\n\nSome insight in the implementation of mana can be found in [this post](http://blog.includeos.org/2016/10/05/middleware-implementation-in-mana).\n\n## Usage\n\nIt's easy to get started - check out the [examples](examples/).\n\n```cpp\nusing namespace mana;\nusing namespace std::string_literals;\n\nstd::unique_ptr\u003cServer\u003e server;\n\nvoid Service::start(const std::string\u0026)\n{\n  Router router;\n\n  // GET /\n  router.on_get(\"/\", [](auto, auto res) {\n    res-\u003eadd_body(\"\u003chtml\u003e\u003cbody\u003e\u003ch1\u003eSimple example\u003c/h1\u003e\u003c/body\u003e\u003c/html\u003e\"s);\n    res-\u003esend();\n  });\n\n  server = std::make_unique\u003cServer\u003e(net::Inet4::stack());\n  server-\u003eset_routes(router).listen(80);\n}\n```\n\n### Routes\n\nRoutes is where the server end-points are defined.\n\n```cpp\nRouter router;\n\n// GET /\nrouter.on_get(\"/\", [] (auto req, auto res) {\n  // Serve index.html\n});\n\n// POST /users\nrouter.on_post(\"/users\", [] (auto req, auto res) {\n  // Register new user\n});\n\nserver.set_routes(router);\n```\n\nThere is also support for named parameters in routes.\n\n```cpp\n// GET /users/:id\nrouter.on_get(\"/users/:id(\\\\d+)\", [](auto req, auto res) {\n  auto id = req-\u003eparams().get(\"id\");\n  // Do actions according to \"id\"\n  if(id == \"42\")\n    // ...\n});\n```\n\n### Middleware\n\nMiddleware are tasks which are executed before the user code defined in routes.\n\n```cpp\n// Declare a new middleware\nclass MyMiddleware : public mana::Middleware {\n  // ...\n};\n\n// Add a middleware object\nMiddleware_ptr my_mw = std::make_shared\u003cMyMiddleware\u003e();\nserver.use(my_mw);\n```\n\nIt's also possible to just add a simple task with a lambda.\n\n```cpp\n// Add a middleware lambda\nserver.use([] (auto req, auto res) {\n  // My custom middleware function\n  (*next)(); // Don't forget to call next if no response was sent!\n});\n```\n\n*Psst, there is already some [ready-made middleware](include/mana/middleware) for Mana!*\n\n\n### Attributes\n\nAttributes is a way to extend the Request object with additional data.\n\n```cpp\n// Declare a new attribute\nclass MyAttribute : public Attribute {\n  // ...\n};\n\n// Set attribute in middleware\nMyMiddleware::process(auto req, auto res, auto next) {\n  auto attr = std::make_shared\u003cMyAttribute\u003e();\n  req-\u003eset_attribute(attr);\n  (*next)();\n}\n\n// Use attribute in route\nrouter.use(\"/my-route\", [] (auto req, auto res) {\n  if(auto attr = req-\u003eget_attribute\u003cMyAttribute\u003e()) {\n    // Do things with \"attr\"\n  }\n});\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fincludeos%2Fmana","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fincludeos%2Fmana","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fincludeos%2Fmana/lists"}