Minor changes
This commit is contained in:
parent
b0704f50a4
commit
2dea10ca62
1 changed files with 5 additions and 4 deletions
|
@ -7,6 +7,7 @@ use std::net::{TcpListener, TcpStream};
|
|||
use urlencoding::decode;
|
||||
|
||||
use crate::database;
|
||||
use crate::database::DatabaseError;
|
||||
use crate::mouth::Mouth;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -68,8 +69,8 @@ impl Ear {
|
|||
Some(req) => req,
|
||||
None => continue,
|
||||
};
|
||||
let mut sender = Mouth::new(&stream);
|
||||
println!("Received request: {}", &req);
|
||||
let mut sender = Mouth::new(&stream);
|
||||
|
||||
match parse_uri(&req) {
|
||||
Ok(req) => handle_request(req, sender),
|
||||
|
@ -174,7 +175,7 @@ fn handle_get_request(request: Request, mut sender: Mouth) {
|
|||
Err(err) => sender.send_internal_error(format!("{}", err)),
|
||||
},
|
||||
_ => sender.send_bad_request(""),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// Handles a given POST request
|
||||
|
@ -193,8 +194,8 @@ fn handle_post_request(request: Request, mut sender: Mouth) {
|
|||
sender.send_ok(format!("Favori inséré avec succès : {}", result.titre))
|
||||
}
|
||||
Err(err) => match err {
|
||||
database::DatabaseError::NotFound => sender.send_not_found(format!("{}", err)),
|
||||
database::DatabaseError::FoundDuplicate => {
|
||||
DatabaseError::NotFound => sender.send_not_found(format!("{}", err)),
|
||||
DatabaseError::FoundDuplicate => {
|
||||
sender.send_bad_request(format!("{}", err).as_str())
|
||||
}
|
||||
_ => sender.send_internal_error(format!("{}", err)),
|
||||
|
|
Loading…
Reference in a new issue