File tree 1 file changed +11
-3
lines changed
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -18,15 +18,23 @@ pub trait IntoTwirpResponse {
18
18
/// use axum::body::Body;
19
19
/// use http::Response;
20
20
/// use twirp::IntoTwirpResponse;
21
- /// # struct MyError { message: &'static str }
21
+ /// # struct MyError { message: String }
22
22
///
23
23
/// impl IntoTwirpResponse for MyError {
24
24
/// fn into_twirp_response(self) -> Response<Body> {
25
- /// twirp::invalid_argument(self.message)
26
- /// .into_twirp_response()
25
+ /// // Use TwirpErrorResponse to generate a valid starting point
26
+ /// let mut response = twirp::invalid_argument(&self.message)
27
+ /// .into_twirp_response();
28
+ ///
29
+ /// // Customize the response as desired.
30
+ /// response.headers_mut().insert("X-Server-Pid", std::process::id().into());
31
+ /// response
27
32
/// }
28
33
/// }
29
34
/// ```
35
+ ///
36
+ /// The `Response` that `TwirpErrorResponse` generates can be used as a starting point,
37
+ /// adding headers and extensions to it.
30
38
fn into_twirp_response ( self ) -> Response < Body > ;
31
39
}
32
40
You can’t perform that action at this time.
0 commit comments