body update and refactor

This commit is contained in:
MeexReay 2024-12-01 02:22:32 +03:00
parent bbfef6daef
commit f352c98e93
3 changed files with 6 additions and 6 deletions

View File

@ -11,7 +11,7 @@ use ezhttp::{
server::{
starter::HttpServerStarter,
HttpServer
}
}, Sendable
};
struct EzSite {
@ -63,7 +63,7 @@ impl EzSite {
}
impl HttpServer for EzSite {
async fn on_request(&self, req: &HttpRequest) -> Option<HttpResponse> {
async fn on_request(&self, req: &HttpRequest) -> Option<impl Sendable> {
println!("{} > {} {}", req.addr, req.method, req.url.to_path_string());
if let Some(resp) = self.get_main_page(req).await {

View File

@ -1,9 +1,9 @@
use ezhttp::prelude::*;
use ezhttp::{prelude::*, Sendable};
struct EzSite(String);
impl HttpServer for EzSite {
async fn on_request(&self, req: &HttpRequest) -> Option<HttpResponse> {
async fn on_request(&self, req: &HttpRequest) -> Option<impl Sendable> {
println!("{} > {} {}", req.addr, req.method, req.url.to_path_string());
if req.url.path == "/" {

View File

@ -110,10 +110,10 @@ impl Body {
Some((name.to_lowercase(), value.to_string()))
}).collect::<Vec<(String, String)>>();
let content_type = head.iter()
.find(|o| o.0 == "content-type")
.find(|o| o.0.to_lowercase() == "content-type")
.map(|o| o.1.clone());
let (name, filename) = head.iter()
.find(|o| o.0 == "content-disposition")
.find(|o| o.0.to_lowercase() == "content-disposition")
.map(|o| o.1.split(";").filter(|o| o == &"form-data").map(|s| s.trim().to_string()).collect::<Vec<String>>())
.map(|o| (
o.iter().find(|k| k.starts_with("name=\"")).map(|k| k[6..k.len()-1].to_string()),