-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: document the pet clinic using axum
- Loading branch information
Ryan Tran
committed
May 5, 2024
1 parent
ac3fb81
commit 34b1f90
Showing
20 changed files
with
273 additions
and
40 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,13 +1,33 @@ | ||
use crate::error::Error; | ||
use crate::repository::owner; | ||
use crate::repository::schema::Owner; | ||
|
||
// trait Servicer { | ||
// fn new() -> Self; | ||
// // new(owner_repo: OwnerRepository) -> Self; | ||
// // fn list_owners(&self) -> Result<Vec<Owner>, Error>; | ||
// fn new(&self, ) -> Self; | ||
// async fn find_owners(&self) -> Result<Vec<Owner>, Error>; | ||
|
||
// } | ||
|
||
// impl Servicer { | ||
// pub fn new() -> Self { | ||
// Self {} | ||
// } | ||
// } | ||
#[derive(Debug)] | ||
struct Service { | ||
repo: owner::Repository, | ||
} | ||
|
||
impl Service { | ||
// fn new(&self) -> Self { | ||
// Self {repo: owner::Repository::new()} | ||
// } | ||
// | ||
// | ||
// async fn find_owners(&self) -> Result<Vec<Owner>, Error> { | ||
// self.repo.list_owners() | ||
// } | ||
async pub fn new() -> Self { | ||
Self { | ||
repo: owner::Repository::new(), | ||
} | ||
} | ||
async fn find_owners(&self) -> Result<Vec<Owner>, Error> { | ||
self.repo.list_owners() | ||
} | ||
} |
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,3 +1,5 @@ | ||
mod service; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use crate::repository::schema; | ||
|
||
|
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,13 @@ | ||
use crate::error::Error; | ||
use crate::repository::schema::{Pet}; | ||
|
||
// trait Servicer { | ||
// async fn new() -> Self; | ||
// async fn find_pets(&self) -> Result<Vec<Pet>, Error>; | ||
// | ||
// } | ||
|
||
#[derive(Debug, Clone)] | ||
struct Service { | ||
// repo: OwnerRepository, | ||
} |
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,3 +1,5 @@ | ||
mod service; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use crate::repository::schema; | ||
|
||
|
Empty file.
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 @@ | ||
mod service; |
Empty file.
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,15 @@ | ||
use sqlx::{Pool, Postgres}; | ||
use sqlx::postgres::PgPoolOptions; | ||
use crate::error::Error; | ||
|
||
pub async fn create_connection() -> Result<Pool<Postgres>, Error> { | ||
let conn_string = "postgresql://postgres:mysecretpassword@localhost:5432/petclinic?sslmode=disable"; | ||
PgPoolOptions::new() | ||
.min_connections(1) | ||
.max_connections(5) | ||
.connect(conn_string) | ||
.await | ||
.map_err(|e| { | ||
Error::new("create_connection", &format!("{:?}", e)) | ||
}) | ||
} |
Oops, something went wrong.