Put request data parsing into separate method
This commit is contained in:
parent
70b29be14d
commit
8e6efef5bb
28
src/main.rs
28
src/main.rs
@ -481,16 +481,8 @@ struct RequestData<'a> {
|
||||
progress: &'a str,
|
||||
}
|
||||
|
||||
fn handle_relative_connection(
|
||||
info: Arc<SiteInfo>,
|
||||
mut stream: TcpStream,
|
||||
body: &str,
|
||||
relative_path: &str,
|
||||
path: &Path,
|
||||
file_paths: DocumentPaths,
|
||||
cookie: Option<&str>,
|
||||
censored: bool,
|
||||
) {
|
||||
impl<'a> RequestData<'a> {
|
||||
fn parse(body: &'a str) -> Self {
|
||||
let mut data = RequestData {
|
||||
name: None,
|
||||
text: None,
|
||||
@ -541,6 +533,20 @@ fn handle_relative_connection(
|
||||
}
|
||||
}
|
||||
|
||||
data
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_relative_connection(
|
||||
info: Arc<SiteInfo>,
|
||||
mut stream: TcpStream,
|
||||
body: &str,
|
||||
relative_path: &str,
|
||||
path: &Path,
|
||||
file_paths: DocumentPaths,
|
||||
cookie: Option<&str>,
|
||||
censored: bool,
|
||||
) {
|
||||
let RequestData {
|
||||
name,
|
||||
text,
|
||||
@ -548,7 +554,7 @@ fn handle_relative_connection(
|
||||
down,
|
||||
choice,
|
||||
progress,
|
||||
} = data;
|
||||
} = RequestData::parse(body);
|
||||
|
||||
let comments = {
|
||||
let Ok(mut comments) = info.comments.lock() else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user