4 releases

0.1.3 Feb 17, 2024
0.1.2 Feb 17, 2024
0.1.1 Feb 17, 2024
0.1.0 Feb 17, 2024

#2 in #status-code

43 downloads per month
Used in heman

MIT license

21KB
536 lines

http-status-codes2

Provides a representation of IANA’s HTTP Status Code Registry and search functions to query it.

Also has an unofficial status code registry whech includes a few proposed or popular unofficial status codes.

A CLI is provided by the heman crate.

Usage exaple for the official registry:

use http_status_codes2::{find_by_code, status_code_registry::CODE_REGISTRY};

assert_eq!(
    find_by_code(100, &CODE_REGISTRY),
    Some((
        100,
        "Continue",
        "[RFC9110, Section 15.2.1]",
        "https://www.rfc-editor.org/rfc/rfc9110.html#section-15.2.1"
    ))
);
assert_eq!(find_by_code(600, &CODE_REGISTRY), None);

Usage exaple for the unofficial registry:

use http_status_codes2::{find_by_substring, status_code_registry::UNOFFICIAL_CODE_REGISTRY};

let mut it = find_by_substring("teapot", &UNOFFICIAL_CODE_REGISTRY);
assert_eq!(
    it.next(),
    Some((
        418,
        "I'm a teapot",
        "[RFC2324, Section 2.3.2]",
        "https://www.rfc-editor.org/rfc/rfc2324.html#section-2.3.2"
    ))
    .as_ref()
);
assert_eq!(it.next(), None);

Dependencies

~630KB