Start rust rewrite
This commit is contained in:
commit
12d57d020f
22 changed files with 2599 additions and 0 deletions
src/handlers
1
src/handlers/mod.rs
Normal file
1
src/handlers/mod.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub mod v1;
|
1
src/handlers/v1/mod.rs
Normal file
1
src/handlers/v1/mod.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub mod schedules;
|
24
src/handlers/v1/schedules.rs
Normal file
24
src/handlers/v1/schedules.rs
Normal 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"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue