Crate maker_web

Crate maker_web 

Source
Expand description

maker_web - High-performance, zero-allocation HTTP server for microservices

A performance-oriented HTTP server with comprehensive configuration for memory management, connection handling, and protocol support. Designed for microservices requiring fine-grained control over resources.

ยงProtocol Support

ยงFeatures

ยง๐Ÿ”’ Security & Protection

  • Built-in DoS/DDoS protection - enabled by default, with no performance penalty.
  • Fully configurable limits and timeouts for requests, responses, and connections.
  • Custom connection filtering - implement the ConnectionFilter trait to reject unwanted connections at the TCP level.

ยง๐Ÿš€ Performance & Memory

  • Zero-allocation - no memory allocations after server startup.
  • Pre-allocated memory for each connection - linear and transparent scaling.

ยง๐ŸŒ Protocol & Management

  • Full HTTP stack - HTTP/1.1, HTTP/1.0, HTTP/0.9+ with keep-alive.
  • Automatic protocol detection for each request - keep-alive eliminates the need for manual protocol selection.
  • Storing data between requests - ability to store data between requests in a single connection using the ConnectionData trait.

ยง๐Ÿญ Production Ready

  • Graceful performance degradation - automatic 503 responses when overloaded.
  • Custom error format - structured JSON (with codes/descriptions) or a plain HTTP response.
  • Resource protection - automatic closure of connections exceeding set limits.

ยงQuick Start

ยง1. Installation

Add maker_web and tokio to your Cargo.toml:

cargo add maker_web tokio --features tokio/full

Or manually:

[dependencies]
maker_web = "0.1"
tokio = { version = "1", features = ["full"] }

ยง2. Usage example

use maker_web::{Server, Handler, Request, Response, Handled, StatusCode};
use tokio::net::TcpListener;

struct MyHandler;

impl Handler for MyHandler {
    async fn handle(&self, _: &mut (), _: &Request, resp: &mut Response) -> Handled {
        resp.status(StatusCode::Ok).body("Hello World!")
    }
}

#[tokio::main]
async fn main() {
    Server::builder()
        .listener(TcpListener::bind("127.0.0.1:8080").await.unwrap())
        .handler(MyHandler)
        .build()
        .launch()
        .await;
}

For more examples including connection filtering and advanced configuration, see the crate documentation and examples/ directory.

ยงUse Cases

  • High-throughput microservices - configurable for specific workloads
  • Resource-constrained environments - predictable memory usage
  • Internal APIs - security-conscious defaults
  • Performance-critical applications - zero-allocation design
  • Legacy system integration - HTTP/1.0 compatibility

ยง๐ŸŒ Beyond the Documentation

For live statistics, deeper insights, and ongoing project thoughts, visit the project website.

Modulesยง

limits
Web server configuration limits and timeouts
query
Zero-copy URL query string parser with flexible collection support.

Structsยง

BodyWriter
Writer for constructing the HTTP response body. Used in body_with.
Request
High-performance HTTP request representation.
Response
HTTP response builder for constructing server responses.
Server
An HTTP server that processes incoming connections and requests.
ServerBuilder
Builder for configuring and creating Server instances.
Url
A parsed URL representation optimized for HTTP request handling.

Enumsยง

Method
HTTP request methods
StatusCode
HTTP status codes
Version
HTTP protocol version

Traitsยง

ConnectionData
Managing user session data stored between requests within a single HTTP connection.
ConnectionFilter
A trait for filtering TCP connections before HTTP processing.
Handler
A trait for handling HTTP requests and generating responses.
WriteBuffer
Trait for writing data to the Response buffer.