7 releases (breaking)

0.7.0 Sep 22, 2024
0.6.0 Sep 20, 2024
0.5.0 Sep 16, 2024
0.4.0 Sep 15, 2024
0.1.0 Sep 12, 2024

#831 in Web programming

Download history 475/week @ 2024-09-10 255/week @ 2024-09-17 57/week @ 2024-09-24 14/week @ 2024-10-01 1/week @ 2024-10-08

562 downloads per month

MIT license

115KB
2.5K SLoC

vintage

Let's take it back to the 1990s. This library implements a multi-threaded server that speaks the FastCGI protocol.

Try it out!

Browsers don't speak FastCGI protocol. Thankfully, most popular web servers do. I'll be using Nginx & Caddy as examples.

  1. Download either Nginx or Caddy
  2. Configure the web server to reverse proxy fastcgi:
    1. If you picked caddy, stick this in a file in the current directory called Caddyfile:

       localhost {
         reverse_proxy localhost:8000 {
           transport fastcgi
         }
       }
      
    2. If you picked nginx, stick this in a file in the current directory called nginx.conf:

       events { }
       http {
         server {
           location / {
             fastcgi_pass localhost:8000;
           }
         }
       }
      
  3. Run the web server
    • Caddy: sudo caddy run --config Caddyfile
    • Nginx: sudo nginx -p $(pwd) -c nginx.conf
  4. Run cargo 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();
    }
    
  5. Run cargo run
  6. Visit http://localhost on your browser!

Similar libraries

Dependencies

~4–11MB
~97K SLoC