-
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from kpcyrd/rocket-4
Port to rocket 0.4
- Loading branch information
Showing
12 changed files
with
558 additions
and
343 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,4 @@ | ||
pub use failure::{Error, ResultExt}; | ||
pub type Result<T> = ::std::result::Result<T, Error>; | ||
|
||
use rocket::Request; | ||
use rocket::http::Status; | ||
use rocket::response::{self, Responder}; | ||
|
||
#[derive(Debug)] | ||
pub struct ApiError(Error); | ||
|
||
#[derive(Serialize)] | ||
pub struct ErrorResponse { | ||
pub status: &'static str, | ||
pub message: String, | ||
} | ||
|
||
pub type ApiResult<T> = ::std::result::Result<T, ApiError>; | ||
|
||
impl<'r> Responder<'r> for ApiError { | ||
fn respond_to(self, _: &Request) -> response::Result<'static> { | ||
error!("Error: {:?}", self.0); | ||
Err(Status::InternalServerError) | ||
} | ||
} | ||
|
||
impl From<Error> for ApiError { | ||
fn from(error: Error) -> ApiError { | ||
ApiError(error) | ||
} | ||
} | ||
pub use rocket_failure::errors::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.