【Rust】axumでstatusコードを返却する

### StatusCodeの種類
StatusCode::OK
StatusCode::NOT_FOUND
StatusCode::BAD_REQUEST
StatusCode::INTERNAL_SERVER_ERROR
StatusCode::CREATED

### レスポンスにStatusCodeを返却する

use axum::{
    response::{IntoResponse, Response},
    http::{StatusCode},
};
//

async fn handle_health() -> impl IntoResponse {
    (StatusCode::NOT_FOUND, format!("Status Code Test: Not Found"))
}

$ curl -X GET 192.168.33.10:3000/healtcurl -X GET 192.168.33.10:3000/health
Status Code Test: Not Found

$ curl -i 192.168.33.10:3000/health
HTTP/1.1 404 Not Found
content-type: text/plain; charset=utf-8
content-length: 27
date: Tue, 25 Feb 2025 07:33:11 GMT

なるほど、エラー時にStatusCodeとメッセージを返却したいですね。