1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//! Cache key extractors for HTTP requests.
//!
//! Extractors generate cache key parts from HTTP request components. They
//! implement the [`Extractor`] trait and can be chained using the builder pattern.
//!
//! # Available Extractors
//!
//! | Extractor | Description |
//! |-----------|-------------|
//! | [`Method`] | Extract HTTP method (GET, POST, etc.) |
//! | [`Path`] | Extract path parameters using patterns like `/users/{id}` |
//! | [`header::Header`] | Extract header values |
//! | [`query::Query`] | Extract query parameters |
//! | [`body::Body`] | Extract from body (hash, JQ, regex) |
//! | [`Version`] | Extract HTTP version |
//!
//! # Builder Pattern
//!
//! Start with [`Method::new()`] and chain other extractors:
//!
//! ```
//! use hitbox_http::extractors::{Method, path::PathExtractor, query::QueryExtractor};
//!
//! # use bytes::Bytes;
//! # use http_body_util::Empty;
//! # use hitbox_http::extractors::{NeutralExtractor, Path, query::Query};
//! let extractor = Method::new()
//! .path("/users/{user_id}/posts/{post_id}")
//! .query("page".to_string())
//! .query("limit".to_string());
//! # let _: &Query<Query<Path<Method<NeutralExtractor<Empty<Bytes>>>>>> = &extractor;
//! ```
//!
//! # Cache Key Structure
//!
//! Each extractor adds [`KeyPart`]s to the cache key. A `KeyPart` has:
//! - A name (e.g., "user_id", "page", "method")
//! - An optional value (e.g., "42", "1", "GET")
//!
//! The final cache key is computed from all collected parts.
//!
//! # Transforms
//!
//! Header and query extractors support value transformations via [`transform::Transform`]:
//! - `Hash`: SHA256 hash (truncated to 16 hex chars)
//! - `Lowercase`: Convert to lowercase
//! - `Uppercase`: Convert to uppercase
//!
//! [`Extractor`]: hitbox::Extractor
//! [`KeyPart`]: hitbox::KeyPart
use PhantomData;
use async_trait;
use ;
use crateCacheableHttpRequest;
pub use Method;
pub use Path;
pub use Version;
/// HTTP method extraction for cache keys.
/// Path parameter extraction for cache keys.
/// Base extractor that produces an empty cache key.
///
/// This is an internal building block used by other extractors. Users should
/// start extractor chains with [`Method::new()`] instead.
///
/// # Type Parameters
///
/// * `ReqBody` - The HTTP request body type. Must implement [`hyper::body::Body`]
/// with `Send` bounds. This parameter propagates through extractor chains
/// to ensure type safety.
///
/// # When You'll Encounter This
///
/// You typically don't create this directly. It appears as the innermost type
/// in extractor chains:
///
/// ```
/// use hitbox_http::extractors::{Method, path::PathExtractor};
///
/// # use bytes::Bytes;
/// # use http_body_util::Empty;
/// # use hitbox_http::extractors::{NeutralExtractor, Path};
/// // The full type is Path<Method<NeutralExtractor<Empty<Bytes>>>>
/// let extractor = Method::new().path("/users/{id}");
/// # let _: &Path<Method<NeutralExtractor<Empty<Bytes>>>> = &extractor;
/// ```