idempotent_proxy_types/
lib.rs

1use http::header::HeaderName;
2use std::time::{SystemTime, UNIX_EPOCH};
3
4pub mod auth;
5
6pub static HEADER_PROXY_AUTHORIZATION: HeaderName = HeaderName::from_static("proxy-authorization");
7pub static HEADER_X_FORWARDED_FOR: HeaderName = HeaderName::from_static("x-forwarded-for");
8pub static HEADER_X_FORWARDED_HOST: HeaderName = HeaderName::from_static("x-forwarded-host");
9pub static HEADER_X_FORWARDED_PROTO: HeaderName = HeaderName::from_static("x-forwarded-proto");
10pub static HEADER_IDEMPOTENCY_KEY: HeaderName = HeaderName::from_static("idempotency-key");
11pub static HEADER_X_JSON_MASK: HeaderName = HeaderName::from_static("x-json-mask");
12pub static HEADER_RESPONSE_HEADERS: HeaderName = HeaderName::from_static("response-headers");
13
14pub fn err_string(err: impl std::fmt::Display) -> String {
15    err.to_string()
16}
17
18/// Returns the current unix timestamp in milliseconds.
19pub fn unix_ms() -> u64 {
20    let ts = SystemTime::now()
21        .duration_since(UNIX_EPOCH)
22        .expect("system time before Unix epoch");
23    ts.as_millis() as u64
24}