summaryrefslogtreecommitdiff
path: root/src/repository/routes.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/repository/routes.rs')
-rw-r--r--src/repository/routes.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/repository/routes.rs b/src/repository/routes.rs
index 6b3a942..634d210 100644
--- a/src/repository/routes.rs
+++ b/src/repository/routes.rs
@@ -3,6 +3,7 @@ use crate::errors::AppErrorResponse;
use crate::repository::models::Repository;
use actix_web::{web, HttpResponse, Responder};
use slog::info;
+use uuid::Uuid;
async fn index(state: web::Data<AppState>) -> impl Responder {
let result = Repository::find_all(state.pool.clone()).await;
@@ -16,6 +17,20 @@ async fn index(state: web::Data<AppState>) -> impl Responder {
}
}
+async fn get_repo(
+ state: web::Data<AppState>,
+ id: web::Path<(Uuid,)>,
+) -> impl Responder {
+ let result = Repository::find(state.pool.clone(), &id.0).await;
+ info!(state.log, "GET /repo/{}/", id.0);
+ result
+ .map(|repo| HttpResponse::Ok().json(repo))
+ .map_err(|e| e)
+}
+
pub fn config(cfg: &mut web::ServiceConfig) {
cfg.service(web::resource("/repo{_:/?}").route(web::get().to(index)))
+ .service(
+ web::resource("/repo/{id}{_:/?}").route(web::get().to(get_repo)),
+ );
}