40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
pub const INVITE_JOIN: &'static str = "/invite/join"; // requires @code
|
|
pub const INVITE_CREATE: &'static str = "/invite/create"; // requires none
|
|
|
|
pub const CHANNELS_LIST: &'static str = "/channels/list"; // requires none
|
|
pub const CHANNELS_CREATE: &'static str = "/channels/create"; // requires @name @kind
|
|
pub const CHANNELS_DELETE: &'static str = "/channels/delete"; // requires @name
|
|
|
|
pub const MESSAGE_SEND: &'static str = "/messsage/send"; // requires @content
|
|
|
|
const DYNAMIC_ROUTE_BASES: [&'static str;1] = [
|
|
"/invites",
|
|
];
|
|
|
|
pub struct DynRoute {
|
|
pub base: String,
|
|
pub dynamic: String,
|
|
}
|
|
|
|
|
|
pub fn resolve_dynamic_route(uri: &str) -> Option<DynRoute> {
|
|
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 {
|
|
Some(DynRoute {
|
|
base: base_ref.into(),
|
|
dynamic: uri.to_string().replace(base_ref, "")
|
|
})
|
|
}
|
|
else {
|
|
None
|
|
}
|
|
}
|