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

Adapter middleware to use types from the http crate.

The Unit application context.

Error code returned by the Unit library.

Error code returned when Unit could not be initialized.

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.

Traits

A request handler that uses types from the http crate.

Type Definitions

Result type returned from methods that have a UnitError error.