-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the loading of db connections in handlers into its own helper fu…
…nction
- Loading branch information
1 parent
c3d558c
commit fedfcce
Showing
5 changed files
with
17 additions
and
10 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use crate::app::db::{DbPool, DbPooledConnection}; | ||
use crate::app::error::AppError; | ||
use actix_web::web; | ||
|
||
pub fn get_connection(db_pool: web::Data<DbPool>) -> Result<DbPooledConnection, AppError> { | ||
db_pool.get().map_err(|e| { | ||
AppError::new(500) | ||
.cause(e) | ||
.message("Failed to load database") | ||
}) | ||
} |
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 @@ | ||
pub mod helpers; |
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ pub mod config; | |
pub mod db; | ||
pub mod error; | ||
pub mod init; | ||
pub mod lib; | ||
pub mod route; | ||
|
||
pub mod models { | ||
|