Echo/reply working
This commit is contained in:
@ -1,7 +1,25 @@
|
||||
use json;
|
||||
|
||||
static ENDPOINTS: [(&str, fn(json::JsonValue) -> json::JsonValue); 1] = [("echo", echo)];
|
||||
|
||||
pub fn is_valid_endpoint(endpoint: &str) -> bool {
|
||||
for (name, _func) in &ENDPOINTS {
|
||||
if endpoint.eq(*name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn endpoint(endpoint: &str, input: json::object::Object) {}
|
||||
pub fn endpoint(endpoint: &str, input: json::JsonValue) -> json::JsonValue {
|
||||
for (name, func) in &ENDPOINTS {
|
||||
if endpoint.eq(*name) {
|
||||
return func(input);
|
||||
}
|
||||
}
|
||||
panic!("invalid endpoint, check with is_valid_endpoint")
|
||||
}
|
||||
|
||||
pub fn echo(input: json::JsonValue) -> json::JsonValue {
|
||||
input
|
||||
}
|
||||
|
Reference in New Issue
Block a user