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
//! Raw HTTP request context and extraction trait for Plexus request extraction.
//!
//! This module defines:
//! - `RawRequestContext` — the raw HTTP view passed through the dispatch chain
//! - `PlexusRequest` — trait for typed field extraction from `RawRequestContext`
//!
//! Defined here (in plexus-core) so that:
//! - The `Activation` trait can reference `RawRequestContext` without a circular dep
//! - The generated dispatch code can call `PlexusRequest::extract` via `#crate_path::request`
use SocketAddr;
use crate;
/// The raw HTTP context available when extracting a typed request struct.
///
/// This is populated from the HTTP upgrade/connection phase and made available
/// to every `#[derive(PlexusRequest)]` extraction.
/// Trait implemented by `#[derive(PlexusRequest)]` structs.
///
/// A `PlexusRequest` struct is a typed view of an inbound HTTP request, where
/// each field is extracted from a specific part of the raw context (cookie,
/// header, query string, peer address, or auth context).
///
/// # Deriving
///
/// Use the `PlexusRequest` derive macro from `plexus_macros`:
///
/// ```ignore
/// use plexus_macros::PlexusRequest;
///
/// #[derive(PlexusRequest)]
/// struct MyRequest {
/// #[from_cookie("access_token")]
/// auth_token: String,
///
/// #[from_header("origin")]
/// origin: Option<String>,
///
/// #[from_peer]
/// peer_addr: Option<std::net::SocketAddr>,
/// }
/// ```
/// Trait for newtype field types that carry their own extraction and validation logic.
///
/// Implement this trait on a newtype wrapper to enable `#[derive(PlexusRequest)]`
/// to extract it without an explicit source annotation. The macro generates:
///
/// ```ignore
/// let field_name = FieldType::extract_from_raw(ctx)?;
/// ```
///
/// for fields of any type that implements `PlexusRequestField`.
/// Parse a named cookie from a raw `Cookie` header value.
///
/// The cookie header value is like `"session=abc; access_token=tok123; other=xyz"`.
/// Returns the value for the first matching key, or `None` if not found.
///
/// This is exported so that the `#[derive(PlexusRequest)]` generated code can call it.