{"id":18459470,"url":"https://github.com/d-holguin/rawrustserver","last_synced_at":"2025-04-23T17:39:45.579Z","repository":{"id":184139023,"uuid":"671106631","full_name":"d-holguin/RawRustServer","owner":"d-holguin","description":"A multi-threaded HTTP server built using only the Rust standard library for practice and learning.","archived":false,"fork":false,"pushed_at":"2025-01-12T22:12:20.000Z","size":46344,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T15:36:54.571Z","etag":null,"topics":["html","http","multithreading","rust"],"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/d-holguin.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}},"created_at":"2023-07-26T14:52:03.000Z","updated_at":"2025-01-12T22:12:24.000Z","dependencies_parsed_at":"2023-07-27T08:37:20.084Z","dependency_job_id":"2f4a110e-6c7d-454e-8d57-ad2ea5d20754","html_url":"https://github.com/d-holguin/RawRustServer","commit_stats":null,"previous_names":["d-holguin/rustthreadpoolserver","d-holguin/rawrustserver"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-holguin%2FRawRustServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-holguin%2FRawRustServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-holguin%2FRawRustServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-holguin%2FRawRustServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d-holguin","download_url":"https://codeload.github.com/d-holguin/RawRustServer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250482002,"owners_count":21437816,"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":["html","http","multithreading","rust"],"created_at":"2024-11-06T08:23:16.033Z","updated_at":"2025-04-23T17:39:45.498Z","avatar_url":"https://github.com/d-holguin.png","language":"Rust","readme":"# RawRustServer\n`RawRustServer`  is a simple multithreaded web server built in Rust for fun and self-learning. It originally expanded on the Rust book's Multi-Threaded Web Server project, which you can find here: https://doc.rust-lang.org/book/ch20-00-final-project-a-web-server.html \nThis only uses the rust standard library which doesn't include a http server, logger, threadpool, etc.\n\n\n## Usage\n\n![Usage Example](/example/usage-example.gif)\n```rust\nfn run_server() -\u003e Result\u003c()\u003e {\n    let database = Arc::new(Database::database_init()?);\n    let router = Router::new()\n        .add_route(\n            HttpMethod::get(\"/home\"),\n            HomeHandler {\n                database: Arc::clone(\u0026database),\n            },\n        )\n        .add_route(HttpMethod::get(\"/styles.css\"), CssHandler)\n        .add_route(HttpMethod::get(\"/favicon.ico\"), FaviconHandler)\n        .add_route(\n            HttpMethod::post(\"/login\"),\n            PostLoginHandler {\n                database: Arc::clone(\u0026database),\n            },\n        )\n        .add_route(HttpMethod::get(\"/images/*\"), GetImageHandler)\n        .add_route(HttpMethod::get(\"/login\"), GetLoginHandler);\n\n    let server = ServerBuilder::new()\n        .address(\"127.0.0.1:8000\")\n        .thread_count(4)\n        .router(router)\n        .build()?;\n    server.run()\n}\n``````\n\n## Logger Utility\n\nThe `Logger Utility` provides a simple and efficient way to log messages both to the terminal and to a file. The logger supports different log levels such as \u003cspan style=\"color:green\"\u003eINFO\u003c/span\u003e and \u003cspan style=\"color:red\"\u003eERROR\u003c/span\u003e.\n\nWhen logging an `INFO` message, it will appear in the terminal as:\n\n\u003cspan style=\"color:green\"\u003e[INFO]\u003c/span\u003e Starting Server...\n\nTo use the logger, first initialize the global logger backend with the desired log file name:\n\n\n```rust\nlogger_backend::init_global_logger(\"logs/server.log\");\n```\nThen you can use the logger anywhere in code like this:\n\n```\nlogger::info(\"Starting Server...\");\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd-holguin%2Frawrustserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd-holguin%2Frawrustserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd-holguin%2Frawrustserver/lists"}