no more warnings + debug
This commit is contained in:
@@ -4,14 +4,14 @@ pub fn init_arrivals_scope() -> actix_web::Scope {
|
|||||||
let scope = web::scope("/arrivals").service(show_arrivals);
|
let scope = web::scope("/arrivals").service(show_arrivals);
|
||||||
scope
|
scope
|
||||||
}
|
}
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveTime;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct Arrival {
|
pub struct Arrival {
|
||||||
a_id: u32,
|
a_id: i32,
|
||||||
time_of_day: NaiveDateTime,
|
time_of_day: NaiveTime,
|
||||||
week_day: u32,
|
week_day: i32,
|
||||||
tram_line: u32,
|
tram_line: i32,
|
||||||
direction: bool,
|
direction: bool,
|
||||||
}
|
}
|
||||||
use web::Data;
|
use web::Data;
|
||||||
@@ -19,11 +19,10 @@ use sqlx::{PgPool, query_as};
|
|||||||
#[get("arrivals")]
|
#[get("arrivals")]
|
||||||
async fn show_arrivals(db_pool: Data<PgPool>) -> impl Responder {
|
async fn show_arrivals(db_pool: Data<PgPool>) -> impl Responder {
|
||||||
let arrivals = query_as!(Arrival, r#"SELECT * FROM arrivals"#)
|
let arrivals = query_as!(Arrival, r#"SELECT * FROM arrivals"#)
|
||||||
.fetch_all(db_pool)
|
.fetch_all(db_pool.get_ref())
|
||||||
.await
|
.await
|
||||||
.expect("Could not fetch arrivals");
|
.expect("Could not fetch arrivals");
|
||||||
HttpResponse::Ok()
|
HttpResponse::Ok()
|
||||||
.content_type("application/json")
|
.content_type("application/json")
|
||||||
.json(arrivals);
|
.json(arrivals)
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder};
|
use actix_web::{post, web, App, HttpResponse, HttpServer, Responder};
|
||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
use witl_api::*;
|
use witl_api::*;
|
||||||
#[post("/echo")]
|
#[post("/echo")]
|
||||||
@@ -10,7 +10,7 @@ mod arrivals;
|
|||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
let (port, address) = init_address();
|
std::env::set_var("RUST_LOG", "debug");
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
App::new()
|
App::new()
|
||||||
.service(echo)
|
.service(echo)
|
||||||
|
|||||||
Reference in New Issue
Block a user