Crates.io | http-status-codes2 |
lib.rs | http-status-codes2 |
version | 0.1.3 |
source | src |
created_at | 2024-02-17 04:34:46.789996 |
updated_at | 2024-02-17 08:18:41.951777 |
description | Library for HTTP status codes |
homepage | |
repository | https://github.com/fleetingbytes/http-status-codes2/ |
max_upload_size | |
id | 1143007 |
size | 21,665 |
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);