feat: add actix impl Responder for Element
This commit is contained in:
parent
c29e2a70f0
commit
6ce848ac5f
3 changed files with 1219 additions and 0 deletions
1204
Cargo.lock
generated
1204
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -8,6 +8,8 @@ edition = "2021"
|
||||||
[features]
|
[features]
|
||||||
default = ["dom", "fs"]
|
default = ["dom", "fs"]
|
||||||
dom = []
|
dom = []
|
||||||
|
actix = ["actix-web"]
|
||||||
fs = []
|
fs = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
actix-web = { version = "4.4.0", optional = true }
|
|
@ -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 {
|
impl ToString for Element {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
|
|
Loading…
Reference in a new issue