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
129
130
131
132
133
134
135
//! # Reinhardt HTTP
//!
//! HTTP request and response handling for the Reinhardt framework.
//!
//! This crate provides core HTTP abstractions including typed request and response types,
//! header handling, content negotiation, file uploads, and middleware composition.
//!
//! ## Quick Start
//!
//! ```rust
//! use reinhardt_http::{Request, Response};
//! use hyper::{Method, HeaderMap};
//!
//! // Build a request
//! let request = Request::builder()
//! .method(Method::GET)
//! .uri("/api/status")
//! .version(hyper::Version::HTTP_11)
//! .headers(HeaderMap::new())
//! .body(bytes::Bytes::new())
//! .build()
//! .unwrap();
//!
//! // Create a simple response
//! let response = Response::ok().with_body("OK");
//! ```
//!
//! ## Architecture
//!
//! Key modules in this crate:
//!
//! - [`request`]: Typed HTTP request wrapper with builder pattern and trusted proxy support
//! - [`response`]: HTTP response with helpers for JSON, streaming, and error responses
//! - [`middleware`]: Middleware trait and composition chain for request processing
//! - [`auth_state`]: Authentication state extensions stored in request context
//! - [`upload`]: File upload handling (in-memory and temporary file backends)
//! - [`chunked_upload`]: Resumable chunked upload session management
//! - [`extensions`]: Typed request extension storage
//!
//! ## Feature Flags
//!
//! | Feature | Default | Description |
//! |---------|---------|-------------|
//! | `parsers` | enabled | Request body parsing (JSON, Form, Multipart) |
//! | `messages` | disabled | Flash message middleware for session-based notifications |
//! | `full` | disabled | Enables all optional features |
//!
//! ## Request Construction
//!
//! Requests are constructed using the builder pattern for type-safe configuration:
//!
//! ```rust
//! use reinhardt_http::Request;
//! use hyper::{Method, HeaderMap};
//!
//! let request = Request::builder()
//! .method(Method::POST)
//! .uri("/api/users")
//! .version(hyper::Version::HTTP_11)
//! .headers(HeaderMap::new())
//! .body(bytes::Bytes::from("request body"))
//! .build()
//! .unwrap();
//! ```
//!
//! ## Response Creation
//!
//! Responses use helper methods and builder pattern:
//!
//! ```rust
//! use reinhardt_http::Response;
//!
//! // Using helpers
//! let response = Response::ok().with_body("Hello, World!");
//!
//! // With JSON
//! let json_response = Response::ok()
//! .with_json(&serde_json::json!({"status": "success"}))
//! .unwrap();
//! ```
pub use AuthState;
pub use ;
pub use Extensions;
pub use MessagesMiddleware;
pub use ;
pub use ;
pub use ;
pub use ;
// Re-export error types from reinhardt-exception for consistency across the framework
pub use ;
/// A convenient type alias for view/endpoint function return types.
///
/// This type alias is commonly used in endpoint handlers to simplify function signatures.
/// It wraps any type `T` (typically `Response`) with a dynamic error type that can
/// represent various kinds of errors that might occur during request processing.
///
/// The `Send + Sync` bounds ensure this type is safe to use across thread boundaries,
/// which is essential for async runtime environments.
///
/// # Examples
///
/// ```
/// use reinhardt_http::{Response, ViewResult};
///
/// async fn hello_world() -> ViewResult<Response> {
/// Ok(Response::ok().with_body("Hello, World!"))
/// }
///
/// #[tokio::main]
/// # async fn main() {
/// let response = hello_world().await.unwrap();
/// assert_eq!(response.status, hyper::StatusCode::OK);
/// # }
/// ```
/// Result type for view handlers using reinhardt's unified Error type.
///
/// This type alias ensures compatibility with `UnifiedRouter::function` which requires
/// `Future<Output = Result<Response>>` where `Result` is `reinhardt_core::exception::Result`.
pub type ViewResult<T> = Result;