progress-banner

This is a starting point for Rust solutions to the "Build Your Own HTTP server" Challenge.

HTTP is the protocol that powers the web. In this challenge, you'll build a HTTP/1.1 server that is capable of serving multiple clients.

Along the way you'll learn about TCP servers, HTTP request syntax, and more.

Note: If you're viewing this repo on GitHub, head over to codecrafters.io to try the challenge.

Implemented Features

  • ✅ TCP Connection Bind on port of choice
  • ✅ HTTP protocol parsing
    • Path variables
    • Headers
    • Body
    • Query parameters
  • ✅ Request parsing and Response writing lifecycle
  • ✅ Concurrency and parallel processing through multithreading
  • ✅ A dynamic router implementation
    • Can handle dynamic path params e.g /product/:id
  • ✅ Data compression with GZip
  • ✅ Example on examples folder

Get started

git clone https://github.com/kariuki-george/codecrafters-http-server.git
cd codecrafters-http-server
mkdir files
cargo run -- --directory ./files/

Test

On another terminal

  • Echo
curl http://localhost:4221/echo/hellofriend
  • Get User-Agent
curl http://localhost:4221/echo/useragent
  • Get Request Params
curl http://localhost:4221/query?page=1&pos=1&cur_pos=1&ads_per_page=20&ads_count=20
  • Write into a file
curl --header "Content-Type: application/text"   --request POST   --data 'Hello from George🤭'   http://localhost:4221/files/user
  • Read from a file
curl http://localhost:4221/files/user