|
| 1 | +//! Request handler traits and utilities. |
| 2 | +//! |
| 3 | +//! This module provides the [`RequestHandler`] trait, which is the core |
| 4 | +//! abstraction for handling HTTP requests in Cot. It is automatically |
| 5 | +//! implemented for async functions taking extractors and returning responses. |
| 6 | +
|
1 | 7 | use std::future::Future; |
2 | 8 | use std::marker::PhantomData; |
3 | 9 | use std::pin::Pin; |
@@ -72,12 +78,6 @@ pub fn into_box_request_handler<T, H: RequestHandler<T> + Send + Sync>( |
72 | 78 | Inner(handler, PhantomData) |
73 | 79 | } |
74 | 80 |
|
75 | | -/// Private marker type used to distinguish `FromRequest` parameter position in |
76 | | -/// trait impls. This is used instead of `()` to avoid coherence conflicts. |
77 | | -#[doc(hidden)] |
78 | | -#[expect(missing_copy_implementations, missing_debug_implementations)] |
79 | | -pub struct FromRequestMarker(()); |
80 | | - |
81 | 81 | macro_rules! impl_request_handler { |
82 | 82 | ($($ty:ident),*) => { |
83 | 83 | impl<Func, $($ty,)* Fut, R> RequestHandler<($($ty,)*)> for Func |
@@ -112,7 +112,7 @@ macro_rules! impl_request_handler { |
112 | 112 |
|
113 | 113 | macro_rules! impl_request_handler_from_request { |
114 | 114 | ($($ty_lhs:ident,)* ($ty_from_request:ident) $(,$ty_rhs:ident)*) => { |
115 | | - impl<Func, $($ty_lhs,)* $ty_from_request, $($ty_rhs,)* Fut, R> RequestHandler<($($ty_lhs,)* $ty_from_request, FromRequestMarker, $($ty_rhs,)*)> for Func |
| 115 | + impl<Func, $($ty_lhs,)* $ty_from_request, $($ty_rhs,)* Fut, R> RequestHandler<($($ty_lhs,)* $ty_from_request, (), $($ty_rhs,)*)> for Func |
116 | 116 | where |
117 | 117 | Func: FnOnce($($ty_lhs,)* $ty_from_request, $($ty_rhs),*) -> Fut + Clone + Send + Sync + 'static, |
118 | 118 | $($ty_lhs: FromRequestHead + Send,)* |
@@ -239,14 +239,16 @@ pub use handle_all_parameters; |
239 | 239 | handle_all_parameters!(impl_request_handler); |
240 | 240 | handle_all_parameters_from_request!(impl_request_handler_from_request); |
241 | 241 |
|
| 242 | +#[rustfmt::skip] // `wrap_comments` breaks local links |
242 | 243 | /// A wrapper around a handler that's used in |
243 | | -/// [`Bootstrapper`](cot::Bootstrapper). |
| 244 | +/// [`Bootstrapper`](../../cot/project/struct.Bootstrapper.html). |
244 | 245 | /// |
245 | 246 | /// It is returned by |
246 | | -/// [`Bootstrapper::into_bootstrapped_project`](cot::Bootstrapper::finish). |
247 | | -/// Typically, you don't need to interact with this type directly, except for |
248 | | -/// creating it in [`Project::middlewares`](cot::Project::middlewares) through |
249 | | -/// the [`RootHandlerBuilder::build`](cot::project::RootHandlerBuilder::build) |
| 247 | +/// [`Bootstrapper::finish()`](../../cot/project/struct.Bootstrapper.html#method.finish). |
| 248 | +/// Typically, you don't need to interact with this type directly, except |
| 249 | +/// for creating it in |
| 250 | +/// [`Project::middlewares()`](../../cot/project/trait.Project.html#method.middlewares) through the |
| 251 | +/// [`RootHandlerBuilder::build()`](../../cot/project/struct.RootHandlerBuilder.html#method.build) |
250 | 252 | /// method. |
251 | 253 | /// |
252 | 254 | /// # Examples |
|
0 commit comments