Start rust rewrite

This commit is contained in:
Tobias Reisinger 2021-11-04 23:37:16 +01:00
commit 12d57d020f
22 changed files with 2599 additions and 0 deletions

1
src/handlers/mod.rs Normal file
View file

@ -0,0 +1 @@
pub mod v1;

1
src/handlers/v1/mod.rs Normal file
View file

@ -0,0 +1 @@
pub mod schedules;

View file

@ -0,0 +1,24 @@
use crate::db;
use actix_web::{HttpResponse, Responder};
pub async fn index() -> impl Responder {
let schedules = db::get_schedules();
HttpResponse::Ok().json(schedules)
}
pub async fn get() -> impl Responder {
"hello from get schedules by id"
}
pub async fn add() -> impl Responder {
let new_schedule = db::create_schedule("TEST");
match new_schedule {
Ok(ok) => HttpResponse::Ok().json(ok),
Err(err) => HttpResponse::InternalServerError().json(err),
}
}
pub async fn delete() -> impl Responder {
"hello from delete schedule"
}