diff --git a/server/src/main.rs b/server/src/main.rs index b6a134b..b8bd142 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -23,6 +23,7 @@ mod auth; use auth::AuthReason; mod routes; +mod invites; fn map_qs(query_string_raw: Option<&str>) -> HashMap<&str, &str> { /* @@ -42,9 +43,9 @@ fn map_qs(query_string_raw: Option<&str>) -> HashMap<&str, &str> { map } -async fn route_dispatcher(resp: &mut Response, meth: &Method, path: &str, params: &HashMap<&str, &str>) { +async fn route_dispatcher(conn: &Conn, resp: &mut Response, meth: &Method, path: &str, params: &HashMap<&str, &str>) { match (meth, path) { - (&Method::GET, routes::INVITE_JOIN) => invites::join_invite_code(&mut resp, meth, path, params), + (&Method::GET, routes::INVITE_JOIN) => invites::join_invite_code(conn, &mut resp, params).await, _ => { *resp.status_mut() = StatusCode::NOT_FOUND; } @@ -61,7 +62,7 @@ async fn main_responder(request: Request) -> Result, hyper: if let Ok(conn) = Conn::from_url(env::var("DATABASE_URL").unwrap()).await { // some more information in the response would be great right about here match auth::wall_entry(path, conn, ¶ms).await { - OpenAuth | Good => route_dispatcher(&mut response, &method, path, ¶ms).await, + OpenAuth | Good => route_dispatcher(&conn, &mut response, &method, path, ¶ms).await, LimitPassed => *response.status_mut() = StatusCode::UNAUTHORIZED, NoKey => *response.status_mut() = StatusCode::UNAUTHORIZED, InternalFailure => *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR