defaults for Dynamic routes in case thigns don't go well

This commit is contained in:
shockrah 2020-07-13 19:42:59 -07:00
parent 1810e5ebc8
commit ed6c19314a

View File

@ -1,6 +1,5 @@
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
@ -11,16 +10,11 @@ const DYNAMIC_ROUTE_BASES: [&'static str;1] = [
"/invites"
];
struct DynRoute {
base: String,
dynamic: String,
pub struct DynRoute {
pub base: String,
pub dynamic: String,
}
impl DynRoute {
fn to_parts(&self) -> (String, String) {
(self.base, self.dynamic)
}
}
pub fn resolve_dynamic_route(uri: &str) -> Option<DynRoute> {
let mut valid = false;
@ -33,10 +27,9 @@ pub fn resolve_dynamic_route(uri: &str) -> Option<DynRoute> {
}
}
if valid {
// split the thing now
Some(DynRoute {
base: base_ref.into(),
dynamic: "asdf".into()
dynamic: uri.to_string().replace(base_ref, "")
})
}
else {