as json fix
This commit is contained in:
parent
e281a87258
commit
6d3d1d1cbd
12
README.md
12
README.md
@ -44,11 +44,11 @@ impl HttpServer for EzSite {
|
||||
|
||||
if req.url.path == "/" {
|
||||
Some(HttpResponse::new(
|
||||
OK, // response status code
|
||||
Headers::from(vec![ // response headers
|
||||
("Content-Type", "text/html"), // - content type
|
||||
("Content-Length", self.0.len().to_string().as_str()) // - content length
|
||||
]), Body::from_text(&self.0.clone()), // response body
|
||||
OK, // response status code
|
||||
Headers::from(vec![ // response headers
|
||||
("Content-Type", "text/html"), // - content type
|
||||
("Content-Length", self.0.len().to_string().as_str()) // - content length
|
||||
]), Body::from_text(&self.0.clone()), // response body
|
||||
))
|
||||
} else {
|
||||
None // close connection
|
||||
@ -56,7 +56,7 @@ impl HttpServer for EzSite {
|
||||
}
|
||||
|
||||
async fn on_start(&self, host: &str) {
|
||||
println!("Http server started on {}", host);
|
||||
println!("Http server started on {host}");
|
||||
}
|
||||
|
||||
async fn on_close(&self) {
|
||||
|
@ -39,7 +39,7 @@ impl Body {
|
||||
}
|
||||
|
||||
pub fn as_json(&self) -> Option<Value> {
|
||||
serde_json::to_value(self.as_text()?).ok()
|
||||
serde_json::from_str(&self.as_text()?).ok()
|
||||
}
|
||||
|
||||
pub fn from_bytes(bytes: &[u8]) -> Body {
|
||||
|
Loading…
x
Reference in New Issue
Block a user