summaryrefslogtreecommitdiff
path: root/src/commit/routes.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commit/routes.rs')
-rw-r--r--src/commit/routes.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/commit/routes.rs b/src/commit/routes.rs
index e49f698..95c0faa 100644
--- a/src/commit/routes.rs
+++ b/src/commit/routes.rs
@@ -23,11 +23,11 @@ async fn index(state: web::Data<AppState>) -> impl Responder {
// Endpoint used for getting one commit
async fn get_commit(
state: web::Data<AppState>,
- hash: web::Path<(String,)>,
+ hash: web::Path<String>,
) -> impl Responder {
- info!(state.log, "GET /commit/{}/", &hash.0);
+ info!(state.log, "GET /commit/{}/", &hash);
- let result = Commit::find(state.pool.clone(), hash.0.clone()).await;
+ let result = Commit::find(state.pool.clone(), hash.clone()).await;
result
.map(|commit| HttpResponse::Ok().json(commit))
@@ -39,14 +39,14 @@ async fn get_commit(
async fn delete_commit(
req: HttpRequest,
state: web::Data<AppState>,
- hash: web::Path<(String,)>,
+ hash: web::Path<String>,
) -> impl Responder {
match req.headers().get(header::AUTHORIZATION) {
Some(x)
if x.to_str().unwrap()
!= env::var("SECRET_KEY").unwrap_or("".to_string()) =>
{
- info!(state.log, "DELETE /commit/{}/ 401", &hash.0);
+ info!(state.log, "DELETE /commit/{}/ 401", &hash);
return Err(AppError {
error_type: AppErrorType::AuthorizationError,
message: Some(
@@ -57,13 +57,13 @@ async fn delete_commit(
}
Some(_) => {}
None => {
- info!(state.log, "DELETE /commit/{}/ 400", &hash.0);
+ info!(state.log, "DELETE /commit/{}/ 400", &hash);
return Ok(HttpResponse::BadRequest().body(""));
}
};
- let result = Commit::delete(state.pool.clone(), &hash.0).await;
- info!(state.log, "DELETE /commit/{}/", &hash.0);
+ let result = Commit::delete(state.pool.clone(), &hash).await;
+ info!(state.log, "DELETE /commit/{}/", &hash);
result
.map(|_| HttpResponse::NoContent().body(""))
@@ -74,9 +74,9 @@ async fn delete_commit(
pub fn config(cfg: &mut web::ServiceConfig) {
cfg.service(
web::scope("/commit")
- .service(web::resource("{_:/?}").route(web::get().to(index)))
+ .service(web::resource("/").route(web::get().to(index)))
.service(
- web::resource("/{hash}{_:/?}")
+ web::resource("/{hash}/")
.route(web::get().to(get_commit))
.route(web::delete().to(delete_commit)),
),