mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-21 03:36:06 +00:00
Change API errors to be JSON
This commit is contained in:
parent
e773a92e53
commit
44a42a177a
3 changed files with 34 additions and 5 deletions
|
|
@ -78,5 +78,24 @@ pub struct SubscribeResponse {
|
|||
pub messages: Vec<SubscribeMessage>,
|
||||
}
|
||||
|
||||
/// General response type returned from all Rojo routes
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct NotFoundError;
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ErrorResponse {
|
||||
kind: ErrorResponseKind,
|
||||
details: String,
|
||||
}
|
||||
|
||||
impl ErrorResponse {
|
||||
pub fn not_found<S: Into<String>>(details: S) -> Self {
|
||||
Self {
|
||||
kind: ErrorResponseKind::NotFound,
|
||||
details: details.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum ErrorResponseKind {
|
||||
NotFound,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue