Add much stuff for rewrite

This commit is contained in:
Tobias Reisinger 2023-11-19 18:54:27 +01:00
parent 4261141c3a
commit bd44dc3183
37 changed files with 1356 additions and 2551 deletions
src/handlers/v1

View file

@ -28,7 +28,8 @@ pub async fn index() -> impl Responder {
}
#[get("/api/v1/schedules/tag/{tag}")]
pub async fn tagged(web::Path((tag,)): web::Path<(String,)>) -> impl Responder {
pub async fn tagged(path: web::Path<(String,)>) -> impl Responder {
let (tag,) = path.into_inner();
let tag_db = get_tag(&tag);
if tag_db.is_err() {
return HttpResponse::from(tag_db.unwrap_err());
@ -42,7 +43,8 @@ pub async fn tagged(web::Path((tag,)): web::Path<(String,)>) -> impl Responder {
}
#[get("/api/v1/schedules/{schedule_id}")]
pub async fn show(web::Path((schedule_uid,)): web::Path<(String,)>) -> impl Responder {
pub async fn show(path: web::Path<(String,)>) -> impl Responder {
let (schedule_uid,) = path.into_inner();
let emgauwa_uid = EmgauwaUid::try_from(schedule_uid.as_str()).or(Err(HandlerError::BadUid));
match emgauwa_uid {
@ -108,9 +110,10 @@ pub async fn add_list(data: web::Json<Vec<RequestSchedule>>) -> impl Responder {
#[put("/api/v1/schedules/{schedule_id}")]
pub async fn update(
web::Path((schedule_uid,)): web::Path<(String,)>,
path: web::Path<(String,)>,
data: web::Json<RequestSchedule>,
) -> impl Responder {
let (schedule_uid,) = path.into_inner();
let emgauwa_uid = EmgauwaUid::try_from(schedule_uid.as_str()).or(Err(HandlerError::BadUid));
if emgauwa_uid.is_err() {
return HttpResponse::from(emgauwa_uid.unwrap_err());
@ -138,7 +141,8 @@ pub async fn update(
}
#[delete("/api/v1/schedules/{schedule_id}")]
pub async fn delete(web::Path((schedule_uid,)): web::Path<(String,)>) -> impl Responder {
pub async fn delete(path: web::Path<(String,)>) -> impl Responder {
let (schedule_uid,) = path.into_inner();
let emgauwa_uid = EmgauwaUid::try_from(schedule_uid.as_str()).or(Err(HandlerError::BadUid));
match emgauwa_uid {