1 unstable release
0.0.6 | May 2, 2021 |
---|
#813 in HTTP server
28KB
698 lines
Webby
Webby is a simple Rust web server that supports HTTP 1.1.
Motivation
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.
Features
Create a simple HTTP server
// Run a server on localhost:8080
fn main() {
webby::create("127.0.0.1", 8080)
.start_listening();
}
Routing
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();
}
Pull request guide
- 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.
Third-party dependencies
I've tried to keep Webby as simple as possible. However, some tasks are just out of scope for this project.
Demo
- Env Logger - a logger that can be configured via environment variables
- DotEnv - load environment variables from a
.env
file
Webby
- Log - lightweight logging facade
Dependencies
~87KB