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
//! Path extraction from HTTP requests.
//!
//! This module provides the [`Path`](crate::extractors::path::Path) extractor for accessing the URI path from
//! incoming HTTP requests. It wraps a reference to the path string, allowing
//! efficient access to the request path without copying the underlying data.
//!
//! # Examples
//!
//! ```rust
//! use tako::extractors::path::Path;
//! use tako::types::Request;
//!
//! async fn handle_path(Path(path): Path<'_>) {
//! println!("Request path: {}", path);
//!
//! // Check specific path patterns
//! if path.starts_with("/api/") {
//! println!("API endpoint");
//! }
//!
//! // Extract path segments
//! let segments: Vec<&str> = path.split('/').filter(|s| !s.is_empty()).collect();
//! println!("Path segments: {:?}", segments);
//! }
//! ```
use Infallible;
use Parts;
use crateFromRequest;
use crateFromRequestParts;
use crateRequest;
/// Path extractor that provides access to the HTTP request path.
///
/// This extractor wraps a reference to the URI path of a request, providing
/// efficient access to the path string without copying the underlying data.
/// It can be used to inspect, validate, or extract information from the request path.
///
/// # Examples
///
/// ```rust
/// use tako::extractors::path::Path;
/// use tako::types::Request;
///
/// async fn handler(Path(path): Path<'_>) {
/// match path {
/// "/health" => println!("Health check endpoint"),
/// "/api/users" => println!("Users API endpoint"),
/// _ if path.starts_with("/static/") => println!("Static file request"),
/// _ => println!("Other path: {}", path),
/// }
/// }
/// ```
;