Webby is a simple Rust web server that supports HTTP 1.1.
The Rust ecosystem comes with a lot of third-party web server crates. A lot of crates are absolutely brilliant, but none of them really teach you how a web server works. This crate allows me to discover how HTTP 1.1 works, how to handle requests, asynchronous programming, and much, much more!
Right now, I wouldn't recommend using this crate in any serious projects. It's simply too slow and unreliable.
// Run a server on localhost:8080
fn main() {
webby::create("127.0.0.1", 8080)
.start_listening();
}
No web server would be complete without any sort of routing, which is why Webby supports routing too.
You can either use functions, or lambda functions. As long as you match the expected function signature, it'll work!
fn index() -> HttpResponse {
println!("This is an index route, it only ever returns HTTP 204.");
HttpResponse::new().no_content()
}
fn main() {
webby::create("127.0.0.1", 8080)
.add_route(HttpMethod::GET, "/", index)
.start_listening();
}
- Create a branch from
master
using the following format:feature/<your-feature-name-here>
. - Make your changes.
- Write unit tests.
- Test your changes.
- Rebase on
master
. - Update the status badge in
README.md
. - Open a pull request.
- Add a proper changelog / pull request description.
I've tried to keep Webby as simple as possible. However, some tasks are just out of scope for this project.
- Env Logger - a logger that can be configured via environment variables
- DotEnv - load environment variables from a
.env
file
- Log - lightweight logging facade