diff --git a/server/src/routes.rs b/server/src/routes.rs index b70244b..1ae9f51 100644 --- a/server/src/routes.rs +++ b/server/src/routes.rs @@ -1,7 +1,45 @@ pub const INVITE_JOIN: &'static str = "/invite/join"; // requires @code pub const INVITE_CREATE: &'static str = "/invite/create"; // requires none +pub const INVITE_USE_BASE: &'static str = "/invite/join"; // no quth pub const CHANNELS_LIST: &'static str = "/channels/list"; // requires none pub const CHANNELS_CREATE: &'static str = "/channels/create"; // requires @name @description -pub const MESSAGE_SEND: &'static str = "/messsage/send"; // requires @content \ No newline at end of file +pub const MESSAGE_SEND: &'static str = "/messsage/send"; // requires @content + +const DYNAMIC_ROUTE_BASES: [&'static str;1] = [ + "/invites" +]; + +struct DynRoute { + base: String, + dynamic: String, +} + +impl DynRoute { + fn to_parts(&self) -> (String, String) { + (self.base, self.dynamic) + } +} + +pub fn resolve_dynamic_route(uri: &str) -> Option { + let mut valid = false; + let mut base_ref = ""; + for base in DYNAMIC_ROUTE_BASES.iter() { + if uri.starts_with(base) { + valid = true; + base_ref = base; + break; + } + } + if valid { + // split the thing now + Some(DynRoute { + base: base_ref.into(), + dynamic: "asdf".into() + }) + } + else { + None + } +} \ No newline at end of file