Add middleware

This commit is contained in:
Tobias Reisinger 2021-11-06 14:54:45 +01:00
parent 483fd60daa
commit e6278176e4
6 changed files with 65 additions and 13 deletions
src/handlers/v1

View file

@ -45,17 +45,10 @@ pub async fn show(web::Path((schedule_uid,)): web::Path<(String,)>) -> impl Resp
}
pub async fn add(post: web::Json<RequestSchedule>) -> impl Responder {
println!("model: {:?}", post);
for period in post.periods.0.iter() {
println!("start: {:?}; end: {:?}", period.start, period.end);
}
let new_schedule = db::create_schedule(&post.name, &post.periods);
match new_schedule {
Ok(ok) => HttpResponse::Ok().json(ok),
Ok(ok) => HttpResponse::Created().json(ok),
Err(err) => HttpResponse::InternalServerError().json(err),
}
}