defaults for Dynamic routes in case thigns don't go well
This commit is contained in:
parent
1810e5ebc8
commit
ed6c19314a
@ -1,6 +1,5 @@
|
|||||||
pub const INVITE_JOIN: &'static str = "/invite/join"; // requires @code
|
pub const INVITE_JOIN: &'static str = "/invite/join"; // requires @code
|
||||||
pub const INVITE_CREATE: &'static str = "/invite/create"; // requires none
|
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_LIST: &'static str = "/channels/list"; // requires none
|
||||||
pub const CHANNELS_CREATE: &'static str = "/channels/create"; // requires @name @description
|
pub const CHANNELS_CREATE: &'static str = "/channels/create"; // requires @name @description
|
||||||
@ -11,16 +10,11 @@ const DYNAMIC_ROUTE_BASES: [&'static str;1] = [
|
|||||||
"/invites"
|
"/invites"
|
||||||
];
|
];
|
||||||
|
|
||||||
struct DynRoute {
|
pub struct DynRoute {
|
||||||
base: String,
|
pub base: String,
|
||||||
dynamic: 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> {
|
pub fn resolve_dynamic_route(uri: &str) -> Option<DynRoute> {
|
||||||
let mut valid = false;
|
let mut valid = false;
|
||||||
@ -33,10 +27,9 @@ pub fn resolve_dynamic_route(uri: &str) -> Option<DynRoute> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if valid {
|
if valid {
|
||||||
// split the thing now
|
|
||||||
Some(DynRoute {
|
Some(DynRoute {
|
||||||
base: base_ref.into(),
|
base: base_ref.into(),
|
||||||
dynamic: "asdf".into()
|
dynamic: uri.to_string().replace(base_ref, "")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user