Skip to main content

http_query/
consts.rs

1//! Method token, header field names and media types for the QUERY method.
2
3use http::Method;
4use std::sync::LazyLock;
5
6/// The HTTP QUERY method token, as defined by RFC 10008.
7pub const METHOD_QUERY: &str = "QUERY";
8
9static QUERY_METHOD: LazyLock<Method> =
10    LazyLock::new(|| Method::from_bytes(b"QUERY").expect("QUERY is a valid method token"));
11
12/// Returns the [`http::Method`] value for QUERY.
13///
14/// This works regardless of whether the linked `http` version predates the
15/// built-in `Method::QUERY` constant.
16pub fn query_method() -> Method {
17    QUERY_METHOD.clone()
18}
19
20/// The `Accept-Query` header field name (RFC 10008 ยง3).
21pub const HEADER_ACCEPT_QUERY: &str = "accept-query";
22/// The `Allow` header field name.
23pub const HEADER_ALLOW: &str = "allow";
24/// The `Content-Type` header field name.
25pub const HEADER_CONTENT_TYPE: &str = "content-type";
26/// The `Content-Location` header field name.
27pub const HEADER_CONTENT_LOCATION: &str = "content-location";
28/// The `Location` header field name.
29pub const HEADER_LOCATION: &str = "location";
30/// The `Accept` header field name.
31pub const HEADER_ACCEPT: &str = "accept";
32
33/// The `application/json` media type.
34pub const MEDIA_TYPE_JSON: &str = "application/json";
35/// The `application/x-www-form-urlencoded` media type.
36pub const MEDIA_TYPE_FORM: &str = "application/x-www-form-urlencoded";