small fix
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"database_url": "sqlite:vote.db",
|
||||
"bind_address": "127.0.0.1:8000"
|
||||
"bind_address": "127.0.0.1:8080"
|
||||
}
|
||||
@@ -179,12 +179,12 @@ async fn get_votes(req: &Request<Incoming>, db: Arc<Mutex<SqlitePool>>) -> Vec<V
|
||||
async fn post(req: Request<Incoming>, db: Arc<Mutex<SqlitePool>>) -> Result<Response<Full<Bytes>>, Error> {
|
||||
let path = req.uri().path();
|
||||
if path != "/post" {
|
||||
return Ok(Response::builder().status(StatusCode::BAD_REQUEST).body(Full::new(Bytes::from("Bad Request"))).unwrap());
|
||||
return Ok(Response::builder().status(StatusCode::BAD_REQUEST).body(Full::new(Bytes::from("Bad Request (Bad Route)"))).unwrap());
|
||||
}
|
||||
let body = req.into_body().collect().await?;
|
||||
let data: Result<Vote, serde_json::Error> = from_reader(body.aggregate().reader());
|
||||
if data.is_err() {
|
||||
return Ok(Response::builder().status(StatusCode::BAD_REQUEST).body(Full::new(Bytes::from("Bad Request"))).unwrap());
|
||||
return Ok(Response::builder().status(StatusCode::BAD_REQUEST).body(Full::new(Bytes::from("Bad Request (Bad Data)"))).unwrap());
|
||||
}
|
||||
let vote = data.unwrap();
|
||||
let timestamp: DateTime<Utc> = DateTime::from(SystemTime::now());
|
||||
@@ -233,7 +233,7 @@ async fn main() {
|
||||
let daemonize = Daemonize::new()
|
||||
.pid_file("/var/vote/server.pid")
|
||||
.chown_pid_file(true)
|
||||
.working_directory(current_directory.to_str().unwrap())
|
||||
.working_directory(current_directory)
|
||||
.stdout(stdout)
|
||||
.stderr(stderr);
|
||||
match daemonize.start() {
|
||||
|
||||
Reference in New Issue
Block a user