{"id":21346998,"url":"https://github.com/milesq/web_server","last_synced_at":"2025-07-12T17:31:32.869Z","repository":{"id":35123454,"uuid":"201815563","full_name":"Milesq/web_server","owner":"Milesq","description":"Write your backend with this dependency-less implementation of HTTP listener","archived":false,"fork":false,"pushed_at":"2023-06-18T15:10:02.000Z","size":279,"stargazers_count":10,"open_issues_count":4,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-31T11:49:41.572Z","etag":null,"topics":["backend"],"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/Milesq.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-11T21:13:39.000Z","updated_at":"2024-05-24T15:03:25.000Z","dependencies_parsed_at":"2022-08-08T05:15:34.769Z","dependency_job_id":null,"html_url":"https://github.com/Milesq/web_server","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/Milesq%2Fweb_server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Milesq%2Fweb_server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Milesq%2Fweb_server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Milesq%2Fweb_server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Milesq","download_url":"https://codeload.github.com/Milesq/web_server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225829064,"owners_count":17530666,"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":["backend"],"created_at":"2024-11-22T02:12:18.250Z","updated_at":"2024-11-22T02:12:18.893Z","avatar_url":"https://github.com/Milesq.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Http Server lib for Rust\n\n[![Build Status](https://travis-ci.com/Milesq/web_server.svg?branch=master)](https://travis-ci.com/Milesq/http_server)\n[![dependency status](https://deps.rs/repo/github/milesq/web_server/status.svg)](https://deps.rs/repo/github/milesq/web_server)\n\n## web_server is a small, dependency-less crate for creating HTTP servers.\n\n### When you coding the backend using Rust, the most annoying thing could be the size of a freamwork and the time needed to compile the application\n\n### The web_server package fixes these problems. web_server has no dependencies, but allows you to create full-fledged servers\n\n#### First server using web_server\n\n```rust\nextern crate web_server;\nweb_server::new()\n   .get(\"/\", Box::new(|request: web_server::Request, mut response: web_server::Response|\n        \"Hello World!\".into()))\n   .launch(80)\n   .unwrap();\n```\n\n#### It's easy!\n\n#### First you must create instance of HttpServer\n\n```rust\nweb_server::new()\n```\n\n#### then you can declare your endpoints. E.g.\n\n```rust\n.get(\"/your/path\", Box::new(|request, default_response| {\n    // There place your logic\n    // This function returns Response\n    \"response text\".into()\n}))\n.post(\"/your/path\", Box::new(|_, _| \"Handler for POST method\"))\n.route(web_server::HttpMethod::DELETE, \"/your/path\", Box::new(|_, _| \"Handler for DELETE method\"))\n.any(\"/your/path\", Box::new(|_, _| \"Handler for any method\"))\n```\n\n#### Now you must run server by launch method\n\n```rust\n.launch(PORT).unwrap()\n```\n\n## Receiving post data\n\ne.g.\n\n```rust\n    use web_server::decoders::x_www_form_urlencoded;\n\n    web_server::new()\n        .post(\"/add-user\", Box::new(|req, _| {\n            println!(\"{}\", req.get_body());\n            let body: HashMap\u003cString, String\u003e = x_www_form_urlencoded(req.get_body().as_str());\n            format!(\n                \"Add new user: {}\",\n                body.get(\"user\").unwrap_or(\u0026String::from(\"Error!\"))\n            )\n            .into()\n        }))\n        .launch(8080)\n        .unwrap();\n```\n\nRead examples/ to know more!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilesq%2Fweb_server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmilesq%2Fweb_server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilesq%2Fweb_server/lists"}