adding some dynamic route basees
new feature to check for open routes
This commit is contained in:
parent
157d133317
commit
32ee49ed08
@ -1,4 +1,3 @@
|
||||
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
|
||||
@ -7,8 +6,13 @@ pub const CHANNELS_DELETE: &'static str = "/channels/delete"; // requires @name
|
||||
|
||||
pub const MESSAGE_SEND: &'static str = "/message/send"; // requires @content
|
||||
|
||||
const DYNAMIC_ROUTE_BASES: [&'static str;1] = [
|
||||
"/invites",
|
||||
pub const SERVER_META: &'static str = "/meta"; // open
|
||||
|
||||
// potentially adding more bases later
|
||||
const DYNAMIC_ROUTE_BASES: [(&'static str, bool);3] = [
|
||||
("/join", true), // open
|
||||
("/public", true), // open : valid sections := neighbors|rules|description
|
||||
("/user", false), // TODO: valid sections := /meta/<name>|/dm/<name>
|
||||
];
|
||||
|
||||
pub struct DynRoute {
|
||||
@ -21,9 +25,9 @@ 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) {
|
||||
if uri.starts_with(base.0) {
|
||||
valid = true;
|
||||
base_ref = base;
|
||||
base_ref = base.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -37,3 +41,15 @@ pub fn resolve_dynamic_route(uri: &str) -> Option<DynRoute> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_open(path: &str) -> bool {
|
||||
let mut ret = false;
|
||||
ret = path == SERVER_META;
|
||||
for route in DYNAMIC_ROUTE_BASES.iter() {
|
||||
if route.1 == true || ret == true{
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user