{"id":17689226,"url":"https://github.com/m1guelpf/lil-http-rs","last_synced_at":"2025-05-06T20:44:26.869Z","repository":{"id":65139130,"uuid":"582935277","full_name":"m1guelpf/lil-http-rs","owner":"m1guelpf","description":"A Rust web framework with no external dependencies","archived":false,"fork":false,"pushed_at":"2022-12-29T00:38:09.000Z","size":36,"stargazers_count":27,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T17:42:52.979Z","etag":null,"topics":["framework","http","rust"],"latest_commit_sha":null,"homepage":"https://docs.rs/lil_http","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/m1guelpf.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":"2022-12-28T09:28:28.000Z","updated_at":"2024-07-06T16:06:08.000Z","dependencies_parsed_at":"2023-01-08T21:49:49.327Z","dependency_job_id":null,"html_url":"https://github.com/m1guelpf/lil-http-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Flil-http-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Flil-http-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Flil-http-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1guelpf%2Flil-http-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m1guelpf","download_url":"https://codeload.github.com/m1guelpf/lil-http-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252769031,"owners_count":21801373,"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":["framework","http","rust"],"created_at":"2024-10-24T11:46:56.289Z","updated_at":"2025-05-06T20:44:26.800Z","avatar_url":"https://github.com/m1guelpf.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lil-http\n\nA barebones HTTP 1.1 framework, built in Rust with no external dependencies (other than tokio).\n\n## Features\n\n- [x] Listening to incoming requests\n- [x] Parsing method, path, query, headers, and body according to the HTTP 1.1 spec\n- [x] Responding to requests with an arbitrary body and headers\n- [x] Helpers for responding with text or JSON\n- [x] Allow defining routes and methods as closures\n- [x] Appropiately routing the request to its function, or 404'ing otherwise\n- [x] Appropiately crafting and returning 405 errors on invalid methods.\n\n## Usage\n\n```rust\nuse lil_http::{Body, Response, Server};\n\n#[tokio::main]\nasync fn main() {\n    let mut http = Server::new().await.unwrap();\n\n    http.routes\n        .get(\"/\", |request| {\n            println!(\"Received {} request to {}\", request.method, request.path);\n\n            Response::text(\n                format!(\n                    \"Hello, {}!\",\n                    request.query.get(\"name\").unwrap_or(\u0026\"World\".to_string())\n                )\n                .as_str(),\n            )\n        })\n        .get(\"/api/user\", |request| {\n            println!(\"Received {} request to {}\", request.method, request.path);\n\n            Response::json(\u0026serde_json::json!({\n                \"name\": \"Miguel Piedrafita\",\n                \"age\": 20,\n            }))\n        })\n        .post(\"/api/hello\", |request| {\n            println!(\"Received {} request to {}\", request.method, request.path);\n\n            let Body::Json(body) = request.body else {\n                return Response::invalid_request();\n            };\n\n            let Some(name) = body.get(\"name\") else {\n                return Response::invalid_request();\n            };\n\n            Response::json(\u0026serde_json::json!({\n                \"message\": format!(\"Hello, {name}!\"),\n            }))\n        });\n\n    http.run().await;\n}\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1guelpf%2Flil-http-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm1guelpf%2Flil-http-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1guelpf%2Flil-http-rs/lists"}