INNER CODE UNIT · Rust

into_response

FeatureProbe/FeatureProbe · server/src/http/mod.rs:171

    fn into_response(self) -> Response {
        let (status, error_message) = match self {
            FPServerError::NotFound(_) => (StatusCode::NOT_FOUND, self.to_string()),
            FPServerError::UserDecodeError => (StatusCode::BAD_REQUEST, self.to_string()),
            _ => (StatusCode::INTERNAL_SERVER_ERROR, self.to_string()),
        };

        let body = Json(json!({
            "error": error_message,
        }));

        (status, cors_headers(), body).into_response()
    }
}

pub fn cors_headers() -> [(HeaderName, &'static str); 4] {
    [
        (header::CONTENT_TYPE, "application/json"),

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…