hyperlane-macros 23.3.2

A comprehensive collection of procedural macros for building HTTP servers with enhanced functionality. This crate provides attribute macros that simplify HTTP request handling, protocol validation, response management, and request data extraction.
Documentation

hyperlane-macros

Procedural Attribute Macros for Hyperlane Routing, Middleware & Hooks

Crates.io Version Docs.rs CI Status Rust 2024 License: MIT

Workspace Overview · API Docs


Overview

hyperlane-macros provides hygienic procedural attribute macros for the hyperlane framework. It eliminates boilerplate around route/middleware inventory registration, HTTP method/host/version guards, response flushing, and typed Context extraction.

Installation

cargo add hyperlane-macros

Usage

use hyperlane::{Context, ServerHook, Status, Stream};

struct HealthRoute;

impl ServerHook for HealthRoute {
    async fn new(_: &mut Stream, _: &mut Context) -> Self {
        Self
    }

    #[hyperlane::send]
    async fn handle(self, stream: &mut Stream, ctx: &mut Context) -> Status {
        ctx.get_mut_response().set_body("ok");
        Status::Reject
    }
}

Verification

cargo run -p hyperlane-cli -- fmt --check
cargo clippy -p hyperlane-macros --all-features --all-targets -- -D warnings
cargo test -p hyperlane-macros --all-features

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For inquiries, please contact the author at root@devhub.vip.