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
use Full;
use Bytes;
/// The HTTP response type used by the framework.
///
/// This is a type alias over [`http::Response`] with a default body type
/// suitable for most responses.
///
/// The default body is a fully-buffered [`Bytes`] payload, but handlers
/// are free to return responses with custom body types if needed.
pub type Response<B = > = Response;
/// Trait for converting a value into an HTTP [`Response`].
///
/// `IntoResponse` is used to normalize different return types from handlers
/// into a concrete response that can be sent to the client.
///
/// This allows handlers to return high-level values (such as strings or
/// domain-specific types) without constructing HTTP responses manually.
///
/// # Example
///
/// ```ignore
/// async fn handler(request: Request, _: ()) -> Result<String, ()> {
/// "Hello, world!".to_string()
/// }
/// ```
/// Identity implementation for [`Response`].
///
/// This allows handlers to return responses directly.
/// Converts a [`String`] into a plain-text HTTP response.
///
/// The string is used as the response body with the default body type.