{"id":19206881,"url":"https://github.com/pkoretic/recurse","last_synced_at":"2025-05-12T17:28:02.157Z","repository":{"id":33046695,"uuid":"36682652","full_name":"pkoretic/recurse","owner":"pkoretic","description":"Qt based micro web framework with middleware design","archived":false,"fork":false,"pushed_at":"2017-01-23T14:41:43.000Z","size":190,"stargazers_count":20,"open_issues_count":13,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-05T20:13:37.789Z","etag":null,"topics":["cpp","micro-framework","qt","server","web-framework"],"latest_commit_sha":null,"homepage":null,"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/pkoretic.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":"2015-06-01T19:11:17.000Z","updated_at":"2024-10-30T07:19:45.000Z","dependencies_parsed_at":"2022-07-12T22:40:27.902Z","dependency_job_id":null,"html_url":"https://github.com/pkoretic/recurse","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Frecurse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Frecurse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Frecurse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Frecurse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkoretic","download_url":"https://codeload.github.com/pkoretic/recurse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253786544,"owners_count":21964169,"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","micro-framework","qt","server","web-framework"],"created_at":"2024-11-09T13:17:18.133Z","updated_at":"2025-05-12T17:28:02.120Z","avatar_url":"https://github.com/pkoretic.png","language":"C++","readme":"# [\u003cimg title=\"Recurse\" src=\"http://i.imgur.com/HJ1oUqY.png\" width=\"810px\" alt=\"Recurse logo\"/\u003e](https://github.com/qaap/recurse.git)\n\n[![License MIT](https://cdn.rawgit.com/qaap/recurse/badges/license.svg)](https://github.com/qaap/recurse/blob/master/LICENSE)\n[![Language (C++)](https://cdn.rawgit.com/qaap/recurse/badges/powered_by-C%2B%2B-blue.svg)](http://en.cppreference.com/w/cpp/language)\n\nRecurse is set to be a modern web micro framework written in latest C++ (14) using\nQt library leveraging all the best features of both worlds.  We strongly\nemphasize on writing a clean and easy to understand code and avoid using\ntemplates to encourage contributions.\n\nRecurse aims to be small with no middlewares bundled in the core. This should\nallow it to be very robust for writing next generation web applications and\nAPIs.\n\nIt is inspired by [Node.js](https://nodejs.org/en) [koa](http://koajs.com) and [Express](http://expressjs.com) micro frameworks.\n\n## Example\n\n\n```\n#include \"recurse.hpp\"\n\nint main(int argc, char *argv[])\n{\n    Recurse app(argc, argv);\n\n    // logger\n    app.use([](auto \u0026ctx, auto next)\n    {\n        qDebug() \u003c\u003c ctx.request.ip;\n        next();\n    });\n\n    // hello world\n    app.use([](auto \u0026ctx)\n    {\n        ctx.response.send(\"Hello world\");\n    });\n\n    app.listen(3000);\n};\n```\n\n## Installation\n\nThis is a header-only library. To use, just include `recurse.hpp` inside your project. See\n[examples](examples) for more information.\n\n**`NOTE`** you also need `context.hpp`, `request.hpp`, `response.hpp` as `recurse.hpp` depends on\nthem.\n\n## Middlewares\n\nThere is no middleware bundled in the core.\nFor example, for routing, one can use [Router](https://github.com/qaap/recurse-router)\n\n```\n#include \"router.hpp\"\n\nint main(int argc, char *argv[])\n{\n    Recurse app(argc, argv);\n\n    Module::Router router;\n\n    router.GET(\"/hello/:user\", [](auto \u0026ctx, auto /* next */)\n    {\n        ctx.response.send(\"Hello World \" + ctx.request.params[\"user\"]);\n    });\n\n    app.listen();\n}\n```\n\n## 404 - Not Found\n\nBy default, if no middleware responds, **Recurse** will respond with `Not Found`\nmessage, and `404` HTTP error code.\n\nTo make your own response, simply add new middleware at the **end** of the list\n```\n// if any middleware before this responds this won't get called\napp.use([](auto \u0026ctx)\n{\n    ctx.response.status(404).send(\"Custom Not Found\");\n});\n```\nFor a complete example see [404 example](https://github.com/qaap/recurse/tree/master/examples/404)\n\nYou can also have it as a **first** middleware (if you already have some first\nmiddleware that does your logging or similar)\n\n```\napp.use([](auto \u0026ctx, auto next, auto prev)\n{\n    next([\u0026ctx, prev]\n    {\n        // this is last code to be called before sending response to client\n        if(ctx.response.status() == 404)\n            ctx.response.body(\"Custom Not Found\");\n\n        prev();\n    });\n});\n```\n\n## Styling\n\nWhen writing code, please use the provided [.clang-format](https://github.com/qaap/recurse/blob/master/.clang-format) file.\nThere is a nice [vim-clang-format](https://github.com/rhysd/vim-clang-format) plugin that you can use in vim.\n\nYou can also call it manually\n\n```\nclang-format -i source.hpp\n\n# to format all files\nfind . -name \"*.hpp\" -or -name \"*.cpp\" | xargs clang-format -i\n\n```\n\nAnd you can also use shortcut command\n```\nclang-format -i -style=\"{BasedOnStyle: WebKit, PointerAlignment: Right, Standard: Cpp11, TabWidth: 4, UseTab: Never, BreakBeforeBraces: Allman, AllowShortFunctionsOnASingleLine: false, ContinuationIndentWidth: 0, MaxEmptyLinesToKeep: 1, NamespaceIndentation: All, AccessModifierOffset: 0}\" source.hpp\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkoretic%2Frecurse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkoretic%2Frecurse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkoretic%2Frecurse/lists"}