Expand description

unit-rs

unit-rs is a safe wrapper around the C libunit library from Nginx Unit, which allows creating Unit applications in Rust.

Currently very few features are supported, but enough are available to inspect all aspects of a request and create a response.

Example

use unit_rs::Unit;
 
fn main() {
    let mut unit = Unit::new();
 
    unit.set_request_handler(|req| {
        let headers = &[("Content-Type", "text/plain")];
        let body = "Hello world!\n";
        req.create_response(headers, body)?;
     
        Ok(())
    });
 
    unit.run();
}

Structs

The Unit application context.

Error code returned by the Unit library.

A request received by the Nginx Unit server.

An object used to send follow-up response bytes to a request, obtained by calling a UnitRequest’s create_response() method. Dropping this object will end the response.

Type Definitions

Result type returned from methods that have a UnitError error.