cgi 0.2.0

Create CGI programmes
Documentation

Easily create CGI (RFC 3875) programmes in Rust based on http

Installation & Usage

Cargo.toml:

[dependencies]
cgi = "0.1"

In the main function, call only cgi::handle(...), with a function that takes a cgi::Request and returns cgi::Response.

extern crate cgi;

fn main() { cgi::handle(|request: cgi::Request| -> cgi::Response {
// ...
})}

Hello World:

extern crate cgi;

fn main() { cgi::handle(|request: cgi::Request| -> cgi::Response {
cgi::html_response(200, "<html><body><h1>Hello World!</h1></body></html>")
})}

It will parse & extract the CGI environmental variables, and HTTP request body to create Request, and convert your Response into the correct format and print to stdout. If this programme is not called as CGI (e.g. missing required environmental variables), it will panic.