| Crates.io | vintage |
| lib.rs | vintage |
| version | 0.7.0 |
| created_at | 2024-09-12 01:58:37.517825+00 |
| updated_at | 2024-09-22 15:16:27.659479+00 |
| description | A multi-threaded FastCGI server |
| homepage | |
| repository | https://github.com/eze-works/vintage |
| max_upload_size | |
| id | 1372416 |
| size | 130,325 |
Let's take it back to the 1990s. This library implements a multi-threaded server that speaks the FastCGI protocol.
Browsers don't speak FastCGI protocol. Thankfully, most popular web servers do. I'll be using Nginx & Caddy as examples.
If you picked caddy, stick this in a file in the current directory called Caddyfile:
localhost {
reverse_proxy localhost:8000 {
transport fastcgi
}
}
If you picked nginx, stick this in a file in the current directory called nginx.conf:
events { }
http {
server {
location / {
fastcgi_pass localhost:8000;
}
}
}
sudo caddy run --config Caddyfilesudo nginx -p $(pwd) -c nginx.confcargo new --bin app && cd app && cargo add vintage, and stick this in main.rs:
use vintage::{ServerConfig, Response};
fn main() {
let config = ServerConfig::new()
.on_get(["/about"], |_req, _params| {
Response::html("<h1>Hello World</h1>")
});
let server = vintage::start(config, "localhost:8080").unwrap();
server.join();
}
cargo runhttp://localhost on your browser!