anycms-core 0.3.0

A unified API response library supporting multiple Rust web frameworks
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#[cfg(feature = "actix")]
use actix_web::{HttpResponse, Responder};
#[cfg(feature = "actix")]
use serde::Serialize;
#[cfg(feature = "actix")]
use crate::result::ApiResult;

/// Actix-web framework integration for ApiResult
#[cfg(feature = "actix")]
impl<T: Serialize> Responder for ApiResult<T> {
    type Body = actix_web::body::BoxBody;

    fn respond_to(self, _req: &actix_web::HttpRequest) -> actix_web::HttpResponse<Self::Body> {
        HttpResponse::Ok().json(self)
    }
}