Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/welf/codecrafters-http-server-rust
Rust solutions to the http-server challenge on Codecrafters
https://github.com/welf/codecrafters-http-server-rust
codecrafters-http-server rust
Last synced: 12 days ago
JSON representation
Rust solutions to the http-server challenge on Codecrafters
- Host: GitHub
- URL: https://github.com/welf/codecrafters-http-server-rust
- Owner: welf
- Created: 2024-06-20T00:20:51.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-06-20T00:23:55.000Z (7 months ago)
- Last Synced: 2024-11-11T17:20:51.744Z (2 months ago)
- Topics: codecrafters-http-server, rust
- Language: Rust
- Homepage:
- Size: 159 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
- [Challenge Status](#challenge-status)
- [Running the Server](#running-the-server)[![progress-banner](https://backend.codecrafters.io/progress/http-server/86635622-46d8-4e71-bff5-ac8a170d13cb)](https://app.codecrafters.io/users/codecrafters-bot?r=2qF)
This is a repo for Rust solutions to the [http-server challenge on Codecrafters](https://codecrafters.io/challenges/http-server).
# Challenge Status
The entry point for this `http-server` implementation is in `src/main.rs`. This simple `http-server`
implementation includes:
- [x] user-friendly API for [parsing HTTP requests](./src/http/request.rs)
- [x] user-friendly, elegant, and type-safe API for [building HTTP responses](./src/http/response_builder.rs)
- [x] support for concurrent connections handling [using thread pool](./src/http/thread_pool.rs) with
a configurable number of threads *(deprecated in favor of async/await)*
- [x] support for concurrent connections handling using multi-threading with async/await
- [x] compression support for the server using the `flate2` crate:
- [x] compresses the response body if the client supports it
- support for the following endpoints:
- [x] `/` - returns `200 OK` status code
- [x] `/echo/` - echoes the string passed by user in the URL
- [x] `/user-agent` - echoes the `User-Agent` header value
- [x] `/files/{filename}` - returns the content of the file with the name `filename` in the specified directory
- [x] `/files/{filename}` - saves the content of the response to the file with the name `filename` in the specified directory# Running the Server
1. Ensure you have `cargo (>=1.70)` installed locally
1. Run `./your_server.sh` to run your program, which is implemented in `src/main.rs`. This command compiles your Rust project,
so it might be slow the first time you run the `http-server` on `http://127.0.0.1:4221`. Subsequent runs will be fast.
1. Open a new tab in the terminal and send requests to the server using `curl` or `netcat`. To test the performance of the server,
you can use the [`oha` CLI tool](https://github.com/hatoo/oha) to send a large number of concurrent requests to the server and
get the performance metrics in a nice TUI interface. An example of how to use `oha` is shown below:
```bash
# Send 10000 requests with 10 concurrent connections
$ oha -n 10000 -c 10 http://127.0.0.1:4221/echo/hello
```