{"id":27455937,"url":"https://github.com/adityamotale/http_rs","last_synced_at":"2025-10-29T22:41:19.495Z","repository":{"id":269289754,"uuid":"906891147","full_name":"AdityaMotale/http_rs","owner":"AdityaMotale","description":"A lightweight and simple HTTP server implementation in Rust","archived":false,"fork":false,"pushed_at":"2024-12-28T14:39:29.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T17:12:48.466Z","etag":null,"topics":["http","rust","tcp-server"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/AdityaMotale.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,"zenodo":null}},"created_at":"2024-12-22T08:09:22.000Z","updated_at":"2024-12-31T14:31:37.000Z","dependencies_parsed_at":"2025-04-11T20:49:49.128Z","dependency_job_id":null,"html_url":"https://github.com/AdityaMotale/http_rs","commit_stats":null,"previous_names":["frozen-beak/http_rs","adityamotale/http_rs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdityaMotale%2Fhttp_rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdityaMotale%2Fhttp_rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdityaMotale%2Fhttp_rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdityaMotale%2Fhttp_rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdityaMotale","download_url":"https://codeload.github.com/AdityaMotale/http_rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249116245,"owners_count":21215143,"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":["http","rust","tcp-server"],"created_at":"2025-04-15T17:12:51.214Z","updated_at":"2025-10-29T22:41:19.421Z","avatar_url":"https://github.com/AdityaMotale.png","language":"Rust","readme":"# 🦀 http_rs\n\nA lightweight and simple HTTP server implementation in Rust\n\n## Quick Start\n\nHere's a simple example of creating a REST API:\n\n```rust\nuse std::io::{self, BufReader};\nuse http_rs::server::{HttpMethod, Request, Response, Server};\nuse serde::{Deserialize, Serialize};\n\n#[derive(Serialize, Deserialize)]\nstruct User {\n    id: u32,\n    name: String,\n}\n\nfn main() -\u003e io::Result\u003c()\u003e {\n    let server = Server::new(\"127.0.0.1:6969\")?;\n    println!(\"Server running on http://127.0.0.1:6969\");\n\n    for stream in server.listen() {\n        match stream {\n            Ok(mut stream) =\u003e {\n                let buf = BufReader::new(stream.try_clone().unwrap());\n\n                if let Ok(req) = Request::new(buf) {\n                    let response = match (req.method, req.route.as_str()) {\n                        (HttpMethod::GET, \"/users\") =\u003e {\n                            let users = vec![\n                                User { id: 1, name: \"Alice\".to_string() },\n                                User { id: 2, name: \"Bob\".to_string() },\n                            ];\n                            Response::new(200).json(\u0026users)\n                        }\n                        (HttpMethod::POST, \"/users\") =\u003e {\n                            if let Some(user) = req.get_json::\u003cUser\u003e() {\n                                Response::new(201).json(\u0026user)\n                            } else {\n                                Response::new(400).json(\u0026\"Invalid JSON\")\n                            }\n                        }\n                        _ =\u003e Response::new(404).json(\u0026\"Not Found\"),\n                    };\n\n                    if let Err(e) = response.send(\u0026mut stream) {\n                        eprintln!(\"Failed to send response: {}\", e);\n                    }\n                }\n            }\n            Err(e) =\u003e eprintln!(\"Connection failed: {}\", e),\n        }\n    }\n\n    Ok(())\n}\n```\n\n## API Documentation\n\n### Server\n\n```rust\n// Create a new server instance\nlet server = Server::new(\"127.0.0.1:8080\")?;\n\n// Listen for incoming connections\nfor stream in server.listen() {\n    // Handle connections\n}\n```\n\n### Request\n\nThe `Request` struct provides access to:\n\n- HTTP method (`GET`, `POST`)\n- Route path\n- Headers\n- Query parameters\n- Request body\n- JSON parsing with `get_json\u003cT\u003e()`\n\n### Response\n\nThe `Response` struct allows:\n\n- Setting status codes\n- Adding headers\n- Sending JSON responses\n- Proper HTTP formatting\n\n## Testing\n\nRun the test suite:\n\n```bash\ncargo test\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadityamotale%2Fhttp_rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadityamotale%2Fhttp_rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadityamotale%2Fhttp_rs/lists"}