[−][src]Crate cgi
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 { // ... })}
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.
Re-exports
pub extern crate http; |
Functions
binary_response | Sends |
empty_response | A HTTP Reponse with no body and that HTTP status code, e.g. |
handle | Call F as a CGI programme. |
html_response | Converts |
string_response | Returns a simple plain text response. |
Type Definitions
Request | A |
Response | A |