diff --git a/src/watches/handlers.rs b/src/watches/handlers.rs index c0578a8..2676320 100644 --- a/src/watches/handlers.rs +++ b/src/watches/handlers.rs @@ -1,3 +1,36 @@ +use axum::{ + extract::{Form, Path, State}, + http::StatusCode, + response::{IntoResponse, Response}, +}; +use sqlx::{query_as, SqlitePool}; +use uuid::Uuid; + +use crate::{ShowKind, User, Watch}; + +//-************************************************************************ +// Error types for Watch creation +//-************************************************************************ + +#[Error] +pub struct WatchAddError(#[from] WatchAddErrorKind); + +#[Error] +#[non_exhaustive] +pub enum WatchAddErrorKind { + UnknownDBError, +} + +impl IntoResponse for WatchAddError { + fn into_response(self) -> Response { + match self.0 { + WatchAddErrorKind::UnknownDBError => { + (StatusCode::INTERNAL_SERVER_ERROR, format!("{self}")).into_response() + } + } + } +} + /// Add a Watch to the whole system pub async fn post_add_watch() {} @@ -5,10 +38,8 @@ pub async fn post_add_watch() {} pub async fn get_watch() {} /// everything the user has saved -pub async fn get_my_watches() {} - -/// Add a Watch to user's to-watch list -pub async fn post_add_to_mine() {} - -/// list of all watches? pub async fn get_watches() {} + +pub async fn get_search_watch() {} + +pub async fn post_search_watch() {} diff --git a/src/watches/mod.rs b/src/watches/mod.rs index 62ebe09..f92df12 100644 --- a/src/watches/mod.rs +++ b/src/watches/mod.rs @@ -1,9 +1,8 @@ use serde::{Deserialize, Serialize}; use uuid::Uuid; -mod handlers; - -pub use handlers::*; +pub mod handlers; +pub mod templates; #[derive( Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, sqlx::Type,