Basic errors

This commit is contained in:
2021-05-18 21:14:20 +02:00
parent 7a5eea3f85
commit 806054144a
4 changed files with 61 additions and 13 deletions

View File

@ -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)),
}
}