setup for api posting to db
This commit is contained in:
parent
0330876377
commit
308c4fb9c5
|
@ -6,6 +6,8 @@ use lettre::{
|
||||||
Message, SmtpTransport, Transport,
|
Message, SmtpTransport, Transport,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use super::errors::ApiError;
|
||||||
|
|
||||||
#[derive(Debug, MultipartForm, Default)]
|
#[derive(Debug, MultipartForm, Default)]
|
||||||
struct CampForm {
|
struct CampForm {
|
||||||
#[multipart(rename = "first-name")]
|
#[multipart(rename = "first-name")]
|
||||||
|
@ -310,3 +312,7 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn store_camp_form(form: CampForm) -> Result<(), ApiError> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
25
src/api/errors.rs
Normal file
25
src/api/errors.rs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum ApiErrorType {
|
||||||
|
DbError,
|
||||||
|
NotFoundError,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ApiErrorType {
|
||||||
|
fn default() -> ApiErrorType {
|
||||||
|
ApiErrorType::NotFoundError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default)]
|
||||||
|
pub struct ApiError {
|
||||||
|
pub message: Option<String>,
|
||||||
|
pub cause: Option<String>,
|
||||||
|
pub error_type: ApiErrorType,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
pub struct ApiErrorResponse {
|
||||||
|
pub error: String,
|
||||||
|
}
|
|
@ -505,6 +505,6 @@ pub async fn health_form(MultipartForm(form): MultipartForm<HealthForm>) -> Http
|
||||||
// HttpResponse::Ok().body("hi")
|
// HttpResponse::Ok().body("hi")
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn post_health_form(_form: HealthForm) -> bool {
|
async fn store_health_form(_form: HealthForm) -> bool {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
pub mod camp_form;
|
pub mod camp_form;
|
||||||
pub mod church_form;
|
pub mod church_form;
|
||||||
|
pub mod errors;
|
||||||
pub mod health_form;
|
pub mod health_form;
|
||||||
pub mod local_trip_form;
|
pub mod local_trip_form;
|
||||||
pub mod mt_form;
|
pub mod mt_form;
|
||||||
|
|
Loading…
Reference in a new issue