| 1 | use ahash::AHashMap; |
| 2 | use serde_json::{from_str, Value}; |
| 3 | use std::sync::LazyLock; |
| 4 | |
| 5 | pub(crate) type ContentMediaTypeCheckType = fn(&str) -> bool; |
| 6 | |
| 7 | pub(crate) fn is_json(instance_string: &str) -> bool { |
| 8 | from_str::<Value>(instance_string).is_ok() |
| 9 | } |
| 10 | |
| 11 | pub(crate) static DEFAULT_CONTENT_MEDIA_TYPE_CHECKS: LazyLock< |
| 12 | AHashMap<&'static str, ContentMediaTypeCheckType>, |
| 13 | > = LazyLock::new(|| { |
| 14 | let mut map: AHashMap<&'static str, ContentMediaTypeCheckType> = AHashMap::with_capacity(1); |
| 15 | map.insert("application/json", is_json); |
| 16 | map |
| 17 | }); |