summaryrefslogtreecommitdiff
path: root/src/repository
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2021-03-14 15:39:00 +0100
committerSanto Cariotti <santo@dcariotti.me>2021-03-14 15:39:00 +0100
commitbf6c4bd75168671a5a0e53f7390ebd4796a6bd57 (patch)
tree0e41323722317500f24d9504478b461a71fee453 /src/repository
parent6afd0e59f62889d44b90193f0d8581668eae9c28 (diff)
chore: add helpers module
Diffstat (limited to 'src/repository')
-rw-r--r--src/repository/routes.rs6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/repository/routes.rs b/src/repository/routes.rs
index 56e42ab..c13af7f 100644
--- a/src/repository/routes.rs
+++ b/src/repository/routes.rs
@@ -1,5 +1,6 @@
use crate::config::AppState;
use crate::errors::AppErrorResponse;
+use crate::helpers::uuid_from_string;
use crate::repository::models::Repository;
use actix_web::{web, HttpResponse, Responder};
use slog::info;
@@ -29,10 +30,7 @@ async fn get_repo(
// I have to match the &id.0 because if it's not a valid Uuid, the server
// must response "Repository not found".
// If I pass a not valid Uuid to Repository::find() it raises an error.
- let uuid: Uuid = match Uuid::parse_str(&id.0) {
- Ok(x) => x,
- Err(_) => Uuid::parse_str("00000000000000000000000000000000").unwrap(),
- };
+ let uuid: Uuid = uuid_from_string(&id.0);
let result = Repository::find(state.pool.clone(), &uuid).await;
info!(state.log, "GET /repo/{}/", id.0);