Skip to content

cristicretu/smolserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

smolserver logo

smolserver - a small http-server written in Rust


✨ Features

  • File Handling: Supports both reading and creating files. Perfect for file manipulation operations through HTTP requests.

  • User Agent Routing: Special handling for requests with the User-Agent header.

  • Echo Route: You can echo back whatever is appended to the /echo/ endpoint, making it useful for quick tests.

  • Educational: Designed primarily as a learning exercise to understand the workings of a basic HTTP server in Rust.

  • Extensible: Despite its simplicity, the server can be further developed and integrated into larger projects.

🛠 How It Works

  • GET /: Returns HTTP 200 for index routes.

  • GET /user-agent: Returns HTTP 200 and echoes back the User-Agent if present in the request headers.

  • GET /echo/{message}: Returns HTTP 200 and echoes back the {message}. For example, a GET request to /echo/hello would return "hello".

  • GET /files/{name_of_file}: If the file exists in the directory (provided as a command line argument), it returns the file with HTTP 200. Otherwise, returns HTTP 404.

  • POST /files/{name_of_file}: Creates a new file in the directory (provided as a command line argument) with the content from the request body. Returns HTTP 201 with a success message.

💡 What to Learn

This is an excellent project to understand:

  • Basic HTTP protocol operations
  • Socket programming in Rust
  • Multi-threading
  • File I/O
  • Simple routing logic

📜 License

This project is open-sourced under the MIT license. See the License file for more information. Free forever.

Happy coding! 🦀

About

a minimalist http server in Rust

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages