Derive Macro IntoResponse
Source #[derive(IntoResponse)]
{
#[into_response]
}
Expand description
§Examples
§Simple usage
use into_response::IntoResponse;
#[derive(IntoResponse)]
struct MyResponse {
message: String,
}
let response = MyResponse {
message: "Hello, world!".to_string(),
};
let response = response.into_response();
assert_eq!(response.status(), axum::http::StatusCode::OK);
§You can also specify a custom status code using the into_response attribute
use into_response::IntoResponse;
#[derive(IntoResponse)]
#[into_response(status = 201)]
struct MyResponse2 {
message: String,
}
let response = MyResponse2 {
message: "Hello, world!".to_string(),
};
let response = response.into_response();
assert_eq!(response.status(), axum::http::StatusCode::CREATED);