Basic errors
This commit is contained in:
@ -1,11 +1,13 @@
|
||||
use crate::database;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json;
|
||||
|
||||
pub fn endpoint(endpoint: &str, input: serde_json::Value) -> serde_json::Result<serde_json::Value> {
|
||||
use crate::database;
|
||||
use crate::error::*;
|
||||
|
||||
pub fn endpoint(endpoint: &str, input: serde_json::Value) -> Result<serde_json::Value, Error> {
|
||||
match endpoint {
|
||||
"echo" => Ok(serde_json::to_value(echo(serde_json::from_value(input)?))?),
|
||||
_ => Ok("{}".into()),
|
||||
_ => Err(Error::new(ErrorKind::InvalidEndpoint)),
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user