feat: add actix impl Responder for Element

This commit is contained in:
Strix 2023-10-14 22:39:16 +02:00
parent c29e2a70f0
commit 6ce848ac5f
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774
3 changed files with 1219 additions and 0 deletions

1204
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -8,6 +8,8 @@ edition = "2021"
[features]
default = ["dom", "fs"]
dom = []
actix = ["actix-web"]
fs = []
[dependencies]
actix-web = { version = "4.4.0", optional = true }

View file

@ -94,6 +94,19 @@ impl Element {
}
}
#[cfg(feature = "actix")]
use actix_web::{HttpRequest, HttpResponse, HttpResponseBuilder, Responder};
#[cfg(feature = "actix")]
impl Responder for Element {
type Body = String;
fn respond_to(self, req: &HttpRequest) -> HttpResponse<Self::Body> {
HttpResponse::Ok()
.body(self.into())
.finish()
}
}
impl ToString for Element {
fn to_string(&self) -> String {
let mut s = String::new();