Skip to content

Commit 9fa2494

Browse files
authored
chore(docs): improve RequestHandler docs (#314)
1 parent 774cfd9 commit 9fa2494

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

cot/src/handler.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,22 @@ use crate::{Error, Result};
1313
///
1414
/// This is the main building block of a Cot app. You shouldn't
1515
/// usually need to implement this directly, as it is already
16-
/// implemented for closures and functions that take a [`Request`]
17-
/// and return a [`Result<Response>`].
16+
/// implemented for closures and functions that take some
17+
/// number of [extractors](crate::request::extractors) as parameters
18+
/// and return some type that [can be converted into a
19+
/// response](IntoResponse).
20+
///
21+
/// # Details
22+
///
23+
/// Cot provides an implementation of `RequestHandler` for functions
24+
/// and closures that:
25+
/// * are marked `async`
26+
/// * take at most 10 parameters, all of which implement [`FromRequestParts`],
27+
/// except for at most one that implements [`FromRequest`]
28+
/// * return a type that implements [`IntoResponse`]
29+
/// * is `Clone + Send + 'static` (important if it's a closure)
30+
/// * return a future that is `Send` (i.e., doesn't hold any non-Send references
31+
/// across await points)
1832
#[diagnostic::on_unimplemented(
1933
message = "`{Self}` is not a valid request handler",
2034
label = "not a valid request handler",

0 commit comments

Comments
 (0)