diff --git a/server-api/src/main.rs b/server-api/src/main.rs index c211b97..5b11d7b 100644 --- a/server-api/src/main.rs +++ b/server-api/src/main.rs @@ -44,13 +44,13 @@ const SHUTDOWN_ERR: u16 = 2; async fn route_dispatcher(pool: &Pool, resp: &mut Response
, meth: &Method, path: &str, params: serde_json::Value) { // At some point we should have some way of hiding this obnoxious complexity - use routes::resolve_dynamic_route; const GET: &Method = &Method::GET; const POST: &Method = &Method::POST; const DELETE: &Method = &Method::DELETE; match (meth, path) { /* INVITES */ (GET, routes::INVITE_CREATE) => invites::create(pool, resp, params).await, + (GET, routes::INVITE_JOIN) => invites::join(pool, resp, params).await, /* CHANNELS */ (GET, routes::CHANNELS_LIST) => channels::list_channels(pool, resp).await, (POST, routes::CHANNELS_CREATE) => channels::create_channel(pool, resp, params).await, @@ -64,26 +64,8 @@ async fn route_dispatcher(pool: &Pool, resp: &mut Response, meth: &Method, /* OWNER */ (POST, routes::SET_NEW_ADMIN) => admin::new_admin(pool, resp, params).await, _ => { - // We attempt dynamic routes as fallback for a few reasons - // 1. theres less of these than there are the static routes - // 2. because of the above and that this is wholly more expensive than static routse - // we can justify putting in tons of branches since we're likely to: - // far jump here, lose cache, and still be be network bound - // Computatinoal bounds are really of no concern with this api since - // we're not doing any heavy calculations at any point - if let Some(route) = resolve_dynamic_route(path) { - match (meth, route.base.as_str()) { - (&Method::GET, routes::DYN_JOIN) => invites::join(pool, resp, params).await, - _ => { - println!("\tNOT FOUND: {}: {}", meth, path); - *resp.status_mut() = StatusCode::NOT_FOUND - } - } - } - else { - println!("\tNOT FOUND: {}: {}", meth, path); - *resp.status_mut() = StatusCode::NOT_FOUND - } + println!("\tNOT FOUND: {}: {}", meth, path); + *resp.status_mut() = StatusCode::NOT_FOUND } } } diff --git a/server-api/src/routes.rs b/server-api/src/routes.rs index 2ad0b06..ce50e59 100644 --- a/server-api/src/routes.rs +++ b/server-api/src/routes.rs @@ -2,6 +2,7 @@ type Rstr = &'static str; pub const INVITE_CREATE: Rstr = "/invite/create"; // @ perms::CREATE_INVITE +pub const INVITE_JOIN: Rstr = "/join"; // @ none for new accounts pub const CHANNELS_LIST: Rstr = "/channels/list"; // requires none pub const CHANNELS_CREATE: Rstr = "/channels/create"; // requires @name @kind perms::CREATE_CHANNEl @@ -16,48 +17,7 @@ pub const GET_ONLINE_MEMBERS: Rstr = "/members/get_online"; pub const SET_PERMS_BY_ADMIN: Rstr = "/admin/setpermisions"; // @requires perms::ADMIN pub const SET_NEW_ADMIN: Rstr = "/owner/newadmin"; // @requiers: owner perms - -// TODO: here be dragons... -// potentially adding more bases later -pub const DYNAMIC_ROUTE_BASES: [(Rstr, bool);3] = [ - ("/join", true), // open - ("/public", true), // open : valid sections := neighbors|rules|description - ("/user", false), // TODO: valid sections := /meta/