{"id":35105867,"url":"https://github.com/kriogenia/rust-http-server","last_synced_at":"2026-05-18T20:03:27.557Z","repository":{"id":39701814,"uuid":"429788277","full_name":"kriogenia/rust-http-server","owner":"kriogenia","description":"HTTP Server developed with Rust","archived":false,"fork":false,"pushed_at":"2022-06-24T23:09:43.000Z","size":95,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-29T12:55:30.658Z","etag":null,"topics":["http","rust","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/kriogenia.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}},"created_at":"2021-11-19T12:22:48.000Z","updated_at":"2022-06-20T02:49:54.000Z","dependencies_parsed_at":"2022-09-20T08:31:24.801Z","dependency_job_id":null,"html_url":"https://github.com/kriogenia/rust-http-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kriogenia/rust-http-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kriogenia%2Frust-http-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kriogenia%2Frust-http-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kriogenia%2Frust-http-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kriogenia%2Frust-http-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kriogenia","download_url":"https://codeload.github.com/kriogenia/rust-http-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kriogenia%2Frust-http-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33189279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","server"],"created_at":"2025-12-27T18:10:06.393Z","updated_at":"2026-05-18T20:03:27.551Z","avatar_url":"https://github.com/kriogenia.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rust-http-server\nMultithread HTTP Server developed with Rust.\n\nThis one is a little project made to address two objectives.\nThe first one is in line with my current status as web developer, to develop my own HTTP Server and \nget a deeper learning about the infrastructure of those.\nAnd the other one is to learn Rust, a language I've been eager to learn. \nAnd damn, it really was a ride.\n\n## Features\n\nThis server can:\n\n* Manage concurrent multiple requests at the same time with multithreading.\n* Easily route as many new endpoints as you wish.\n* Support nested and dedicated handlers/routing.\n* Implement REST and work with the different `METHOD` types.\n* Build different types of Responses.\n* Append Headers to Responses.\n* Handle, map and compute query parameters.\n* Serve static pages and resources.\n* Accept different and customizable request handlers.\n* Manage gracefully all known errors.\n* Evade Directory Traversal Attacks.\n\n## Deployment\n\nTo be able to deploy this server you'll need to have Rust installed on your system.\nOnce it's installed you can clone the repo and use the following command to execute it in the port 8080.\n\n```shell\ncd http_server\ncargo run --release\n```\n\nIt's also possible to use the following environment variables to customize the server:\n\n* **RUST_SERVER_ADDRESS**: to set the IP address for the server.\n* **RUST_SERVER_PORT**: to specify the port where the server will be listening.\n* **RUST_SERVER_PUBLIC_PATH**: to establish the path to use as public assets route.\n\n## Usage\n\nOnce the server is deployed it can be tested calling the different endpoints, for example:\n\n```shell\ncurl -XGET \"http://127.0.0.1:8080/hello\"\n```\n\nOr just navigating to [http://127.0.0.1:8080/](http://127.0.0.1:8080/) to see the index page.\nGoing any other endpoint in your browser will yield the 404 page.\n\nAside from that, the server also has an API REST with its own and more powerful Hello World!,\nbecause it accepts a custom name to generate the salute using query parameters.\n\n```shell\ncurl -XGET \"http://127.0.0.1:8080/api/hello\"\ncurl -XGET \"http://127.0.0.1:8080/api/hello?name=Kaladin\"\n```\n\nAnd finally, a complete and working REST interface using different methods to handle a counter.\nYou can try the following requests to test it.\n\n```shell\ncurl -XGET \"http://127.0.0.1:8080/api/count\"\ncurl -XPOST \"http://127.0.0.1:8080/api/count\"\ncurl -XPOST \"http://127.0.0.1:8080/api/count?value=3\"\ncurl -XDELETE \"http://127.0.0.1:8080/api/count\"\ncurl -XPOST \"http://127.0.0.1:8080/api/count?value=NaN\"\n```\n\n## Design\n\nWARNING: this is outdated and needs a fix\nThe follow diagram represents the architecture and design of the server.\nThe overall flow starts with the creation of a new Server with the address it will be deployed on.\nThat server can be launch providing it a request Handler.\n\nIn this basic server the Handler are also the Routers, but that logic could be easily extracted.\nThere's also a MultiHandler using the composite pattern to allow the Server to work with more than one handler.\nIn this prototype we also created a WebHandler and an ApiHandler, the first one serves the html pages\nand the other one responds to API REST requests returning JSON responses.\nBoth Handlers use a FileReader that reads and returns the content of the requested public file.\nIt also provides protection against Directory Traversal Attacks.\n\nEach request comes from a TcpListener of the Server that it's parsed into a Request.\nRequests contain the method, protocol, headers and query parameters of the request.\nThe entities implementing the Handler trait receive those requests and generate a Response\nif they how to satisfy the Request.\nThose Responses are then returned to the Server and from there to the client.\n\n![Server Class Diagram](RustHttpServer.drawio.svg)\n\nHope you liked it!!!\n\n![Ferris](public/img/rustacean-flat-happy.svg)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkriogenia%2Frust-http-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkriogenia%2Frust-http-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkriogenia%2Frust-http-server/lists"}