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
//! Header extraction from HTTP requests.
//!
//! This module provides the [`HeaderMap`](crate::extractors::header_map::HeaderMap) extractor for accessing HTTP headers from
//! incoming requests. It wraps a reference to the headers, allowing efficient access
//! to header values without copying the underlying data.
//!
//! # Examples
//!
//! ```rust
//! use tako::extractors::header_map::HeaderMap;
//! use tako::types::Request;
//!
//! async fn handle_headers(HeaderMap(headers): HeaderMap<'_>) {
//! // Check for specific headers
//! if let Some(user_agent) = headers.get("user-agent") {
//! println!("User-Agent: {:?}", user_agent);
//! }
//!
//! // Iterate over all headers
//! for (name, value) in headers.iter() {
//! println!("{}: {:?}", name, value);
//! }
//! }
//! ```
use Infallible;
use Parts;
use crateFromRequest;
use crateFromRequestParts;
use crateRequest;
/// Header map extractor that provides access to HTTP request headers.
///
/// This extractor wraps a reference to the headers of a request, providing
/// efficient access to header values without copying the underlying data.
/// It can be used to inspect, validate, or extract information from HTTP headers.
///
/// # Examples
///
/// ```rust
/// use tako::extractors::header_map::HeaderMap;
/// use tako::types::Request;
///
/// async fn handler(HeaderMap(headers): HeaderMap<'_>) {
/// // Get authorization header
/// if let Some(auth) = headers.get("authorization") {
/// if let Ok(auth_str) = auth.to_str() {
/// println!("Authorization: {}", auth_str);
/// }
/// }
///
/// // Check content type
/// if let Some(content_type) = headers.get("content-type") {
/// println!("Content-Type: {:?}", content_type);
/// }
/// }
/// ```
;