2 stable releases

new 1.0.1 Dec 21, 2024
1.0.0 Dec 20, 2024

#527 in HTTP server

47 downloads per month

GPL-3.0-only

15KB

Arara - A simple cgi library

arara, is a simple cgi protocol implementation in rust.

So, what's cgi

cgi is a web server protocol used to create simple http server implementation.

The cgi protocol runs the cgi program and give the request in stdin, and get the response in stdout. It was very used in birth of the internet, on 1990's

How does Arara work

The arara is a async library that give the request through function args that wrappes the arara::startup macro, and get the response through firstly the Response struct and secondly is returned the Response struct to give for cgi protocol

Inside the Response struct you can set the content type to another, but the default is "text/html". Same thing to method, you can set to another, but the default is "OK 200"

Example

use arara::startup;
use arara::Request;
use arara::Response;
use arara::CgiError;
use arara::StatusCode;

#[startup]
async fn main(req: Result<Request, CgiError>) -> Response {
    let mut res = Response::new();
    if let Err(e) = req {
        res.status = StatusCode::InternalServerError;
        res.body = e.to_str()
    } else {
        res.body = "pong"
    }

    res
}

Dependencies

~0.9–1.5MB
~32K SLoC