Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fa5985
commit d758f2f
Showing
4 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ futures = "^0.1" | |
env_logger = "^0.6" | ||
failure = "^0.1.5" | ||
reqwest = "^0.9.14" | ||
actix = { version = "^0.7" } |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use actix::{Handler, Message}; | ||
use diesel::query_dsl::RunQueryDsl; | ||
use diesel::MysqlConnection; | ||
use models::NewQuestion; | ||
use DbExecutor; | ||
|
||
impl Message for NewQuestion { | ||
type Result = Result<(), super::error::Db>; | ||
} | ||
|
||
impl Handler<NewQuestion> for DbExecutor { | ||
type Result = Result<(), super::error::Db>; | ||
|
||
fn handle(&mut self, msg: NewQuestion, _ctx: &mut Self::Context) -> Self::Result { | ||
use schema::questions::dsl::questions; | ||
let connection: &MysqlConnection = &self.0.get().unwrap(); | ||
|
||
diesel::insert_into(questions) | ||
.values(&msg) | ||
.execute(connection) | ||
.expect("Error saving the question"); | ||
|
||
Ok(()) | ||
} | ||
} |