Noggin
A declarative, zero-copy, proc-macro based header parser for Rust.
Table of Contents
Features
- Declarative: Define your HTTP headers using Rust structs with strongly typed header values.
- Zero-copy capture: Opt-in zero-copy header value parsing.
- Extensible: Easily add new strongly typed header values.
Examples
Define your HTTP header structure and derive the parsing logic using noggin::Noggin
:
use ;
let raw_headers = b"content-type: text/html\r\n\
content-length: 12\r\n\
accept: text/html, text/plain\r\n\
pragma: no-cache, public\r\n\
accept: application/json\r\n\r\n\
hello world!";
let = parse_headers.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Testing
Tests should run fine with the standard cargo test
.
However, for consistency, we recommend using the dockerized test environment.
To use the dockerized test environment the only requirements are make
and
docker
(you don't even need rust installed locally). Simply run the
following command.
make test