Expand description
Allows you to let an external process handle the request through CGI.
This module provides a trait named CgiRun
which is implemented on std::process::Command
.
In order to dispatch a request, simply start building a Command
object and call start_cgi
on it.
§Example
use std::process::Command;
use rouille::cgi::CgiRun;
rouille::start_server("localhost:8080", move |request| {
Command::new("php-cgi").start_cgi(request).unwrap()
});
§About the Result returned by start_cgi
The start_cgi
method returns a Result<Response, std::io::Error>
. This object will contain
an error if and only if there was a problem executing the command (for example if it fails to
start, or starts then crashes, …).
If the process returns an error 400 or an error 404 for example, then the result will contain
Ok
.
It is therefore appropriate to simply call .unwrap()
on that result. Any panic will be turned
into an error 500 and add an entry to the logs, which is probably what you want when your
server is misconfigured.
Enums§
- Error that can happen when parsing the JSON input.