{"id":16795143,"url":"https://github.com/mehcode/actix-web-async-await","last_synced_at":"2025-03-17T03:30:54.983Z","repository":{"id":57479104,"uuid":"154796538","full_name":"mehcode/actix-web-async-await","owner":"mehcode","description":"Provides a preview of Actix with async/await support.","archived":false,"fork":false,"pushed_at":"2019-02-25T23:13:45.000Z","size":11,"stargazers_count":54,"open_issues_count":2,"forks_count":11,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-09T01:46:58.701Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mehcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-26T07:42:22.000Z","updated_at":"2024-11-28T16:34:08.000Z","dependencies_parsed_at":"2022-08-30T02:31:04.336Z","dependency_job_id":null,"html_url":"https://github.com/mehcode/actix-web-async-await","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehcode%2Factix-web-async-await","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehcode%2Factix-web-async-await/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehcode%2Factix-web-async-await/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehcode%2Factix-web-async-await/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mehcode","download_url":"https://codeload.github.com/mehcode/actix-web-async-await/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243841204,"owners_count":20356441,"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-10-13T09:15:31.419Z","updated_at":"2025-03-17T03:30:54.666Z","avatar_url":"https://github.com/mehcode.png","language":"Rust","readme":"# Actix Web Async/Await Preview\n\u003e This crate provides a preview of Actix with async/await support.\n\n## Usage\nTo use this crate, you need to start with a Rust 2018 edition crate.\n\nAdd this to your Cargo.toml:\n\n```toml\n# In the `[package]` section\nedition = \"2018\"\n\n# In the `[dependencies]` section\nactix-web-async-await = \"0.1.0\"\n```\n\nThen, get started. Here is the [headline Actix example](https://github.com/actix/actix-web#example) with the addition that it asynchronously delays the request by 2 seconds.\n\nThe general idea is to wrap your `async fn` handlers in `compat`. There are `compat2`, `compat3`, etc. for routes taking multiple arguments.\n\n```rust\n#![feature(await_macro, futures_api, async_await)]\n\nuse actix_web::{http, server, App, Path, Responder, Result};\nuse actix_web_async_await::{await, compat};\nuse std::time::{Instant, Duration};\nuse tokio::timer::Delay;\n\nasync fn index(info: Path\u003c(u32, String)\u003e) -\u003e Result\u003cimpl Responder\u003e {\n    // Wait 2s\n    await!(Delay::new(Instant::now() + Duration::from_secs(2)))?;\n\n    // Proceed with normal response\n    Ok(format!(\"Hello {}! id:{}\", info.1, info.0))\n}\n\nfn main() {\n    server::new(\n        || App::new()\n            .route(\"/{id}/{name}/index.html\", http::Method::GET, compat(index)))\n        .bind(\"127.0.0.1:8080\").unwrap()\n        .run();\n}\n\n```\n\nNote that your `async fn` handlers must return `Result` currently. This is both because they are being converted to `futures v0.1` which requires an error type _and_ because nearly the entire rust async ecosystem uses `futures v0.1` which is going to have errors on all futures. An error-less `compat` could be provided if the support is wanted.\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0\n   ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license\n   ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmehcode%2Factix-web-async-await","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmehcode%2Factix-web-async-await","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmehcode%2Factix-web-async-await/lists"}