{"id":28634488,"url":"https://github.com/syedahkam/swim","last_synced_at":"2025-10-06T04:49:37.510Z","repository":{"id":65675577,"uuid":"584214954","full_name":"SyedAhkam/swim","owner":"SyedAhkam","description":"A batteries included rust web framework  ⚡🏊 ","archived":false,"fork":false,"pushed_at":"2024-03-22T16:22:01.000Z","size":2010,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-28T06:29:40.361Z","etag":null,"topics":["async","rust","web","web-framework"],"latest_commit_sha":null,"homepage":"https://docs.rs/swim","language":"Rust","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/SyedAhkam.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-01-01T21:31:32.000Z","updated_at":"2025-07-10T13:30:14.000Z","dependencies_parsed_at":"2024-03-22T17:58:14.887Z","dependency_job_id":null,"html_url":"https://github.com/SyedAhkam/swim","commit_stats":{"total_commits":62,"total_committers":1,"mean_commits":62.0,"dds":0.0,"last_synced_commit":"8188b13dff511a7300a28b3d6b2916e8b73d12de"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/SyedAhkam/swim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyedAhkam%2Fswim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyedAhkam%2Fswim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyedAhkam%2Fswim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyedAhkam%2Fswim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SyedAhkam","download_url":"https://codeload.github.com/SyedAhkam/swim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyedAhkam%2Fswim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278561275,"owners_count":26006954,"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-06T02:00:05.630Z","response_time":65,"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":["async","rust","web","web-framework"],"created_at":"2025-06-12T16:14:21.829Z","updated_at":"2025-10-06T04:49:37.477Z","avatar_url":"https://github.com/SyedAhkam.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swim ⚡🏊\n\n[![Crates.io](https://img.shields.io/crates/v/swim)](https://crates.io/crates/swim)\n[![docs.rs](https://img.shields.io/docsrs/swim)](https://docs.rs/swim)\n[![Crates.io](https://img.shields.io/crates/d/swim)](https://crates.io/crates/swim)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/SyedAhkam/swim/build-and-test.yml?style=plastic)](https://github.com/SyedAhkam/swim/actions/workflows/build-and-test.yml)\n[![Crates.io](https://img.shields.io/crates/l/swim)](LICENSE)\n\n![](assets/swim.png)\n\n\u003c!-- cargo-rdme start --\u003e\n\nAn opinionated batteries-included approach to a rust web framework.\n\nThe idea is to take the best parts of the rust ecosystem and combine them into a framework that is easy to use and provides a good developer experience.\n\n## Installation\n\nAdd the following to your `Cargo.toml` file.\n\n```toml\n[dependencies]\nswim = \"0.2\"\n```\n\n## Features\n\n- Go blazingly fast with [hyper](https://github.com/hyperium/hyper) and [tokio](https://github.com/tokio-rs/tokio)\n- Powerful routing with [routerify](https://github.com/routerify/routerify)\n- CLI tooling with [cargo-swim](cargo-swim) (coming soon)\n- Database support with [SeaORM](https://github.com/SeaQL/sea-orm) (planned)\n- Templating with [Tera](https://github.com/Keats/tera) (planned)\n- Dependency injection (planned)\n\n## Building a project\n\nYou define a project by defining a struct that implements the `Project` trait. It is the highest-level abstraction in the framework. It is responsible for defining the settings, apps, and middleware for your project.\n\n```rust\nuse swim::prelude::*;\n\nstruct MyProject;\n\nimpl Project for MyProject {\n    fn settings(\u0026self) -\u003e Settings {\n        Settings::builder()\n            .extend_ron(relative!(\"settings.ron\"))\n            .build()\n            .unwrap()\n    }\n\n    fn apps(\u0026self) -\u003e Vec\u003cBox\u003cdyn App\u003e\u003e {\n        vec! [\n            MyApp.into()\n        ]\n    }\n\n    fn middleware(\u0026self) -\u003e Vec\u003cBox\u003cdyn Middleware\u003e\u003e {\n        vec! [\n            MyMiddleware.into()\n        ]\n    }\n}\n\n```\n\n## Building apps\n\nYou define an app by defining a struct that implements the `App` trait. It is responsible for defining the routes and views for your app.\n\n```rust\nuse swim::prelude::*;\n\nstruct MyApp;\n\nimpl App for MyApp {\n    fn mount(\u0026self) -\u003e \u0026'static str {\n        \"/\"\n    }\n\n    fn config(\u0026self) -\u003e AppConfig {\n        AppConfig::with_name(\"MyApp\")\n    }\n\n    fn models(\u0026self) -\u003e Vec\u003cBox\u003cdyn Model\u003e\u003e {\n        vec! []\n    }\n\n    fn routes(\u0026self) -\u003e Vec\u003cRoute\u003e {\n        vec! [\n            Route::new(\"/\", IndexView),\n            Route::new(\"/hello\", HelloView),\n            Route::new(\"/greeting/:name\", GreetingView),\n        ]\n    }\n}\n\n```\n\n## Building views\n\nYou define a view by defining a struct that implements the `View` trait. It is responsible for handling the request and returning a response. You can implement the specific HTTP methods you want to handle.\n\n```rust\n#[derive(Debug)]\npub struct HelloView;\n\n#[async_trait::async_trait]\nimpl View for HelloView {\n    async fn get(\u0026self, request: Request\u003cBody\u003e) -\u003e Result\u003cResponse\u003cBody\u003e\u003e {\n        Ok(Response::builder()\n            .status(StatusCode::OK)\n            .body(Body::from(\"Say hello to Swim! \"))\n            .unwrap())\n    }\n\n    async fn post(\u0026self, request: Request\u003cBody\u003e) -\u003e Result\u003cResponse\u003cBody\u003e\u003e {\n        Ok(Response::builder()\n            .status(StatusCode::OK)\n            .body(Body::from(\"It's a post request! \"))\n            .unwrap())\n    }\n}\n\n```\n\n## Defining middlewares\n\nYou define a middleware by defining a struct that implements the `Middleware` trait. You may hook into the `pre` and `post` methods which are capable of modifying the upcoming request and leaving response respectively (or you could simply use these for monitoring traffic).\n\n```rust\n#[derive(Debug)]\npub struct Logger;\n\n#[async_trait::async_trait]\nimpl Middleware for Logger {\n    async fn pre(\u0026self, request: Request\u003cBody\u003e) -\u003e Result\u003cRequest\u003cBody\u003e\u003e {\n        println! (\"New request: {:?}\", request.uri());\n\n        Ok(request)\n    }\n\n    async fn post(\u0026self, response: Response\u003cBody\u003e) -\u003e Result\u003cResponse\u003cBody\u003e\u003e {\n        println! (\"Response: {:?}\", response.status());\n\n        Ok(response)\n    }\n}\n```\n\n## Running the project\n\nYou may use the elegant swim macro to run your project.\n\n```rust\n#[tokio::main(flavor = \"multi_thread\")]\nasync fn main() {\n    swim! (MyProject, host = \"localhost\", port = 8000);\n}\n```\n\n\u003c!-- cargo-rdme end --\u003e\n\n\n## Current status\n\nThe device has been built, but the batteries are not yet included.\n\n## Contributing\n\nFeel free to open an issue or a PR if you have any ideas or suggestions. This project is all about new ideas and making the developer experience better.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyedahkam%2Fswim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyedahkam%2Fswim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyedahkam%2Fswim/lists"}