From ce7b7f1e4c5fb3a98d694b0a72c455b5a0a3a57a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joona=20K=C3=A4rkk=C3=A4inen?= Date: Fri, 2 Feb 2024 16:29:43 +0200 Subject: [PATCH] chore: reduce unneccessary code --- src/api/invoices.rs | 6 ++---- src/api/mod.rs | 9 ++------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/api/invoices.rs b/src/api/invoices.rs index 43c550b..e0840b0 100644 --- a/src/api/invoices.rs +++ b/src/api/invoices.rs @@ -147,8 +147,6 @@ pub async fn create( )) } -pub async fn list_all( - mut conn: DatabaseConnection, -) -> Result<(StatusCode, Json>), Error> { - Ok((StatusCode::OK, axum::Json(conn.list_invoices().await?))) +pub async fn list_all(mut conn: DatabaseConnection) -> Result>, Error> { + Ok(axum::Json(conn.list_invoices().await?)) } diff --git a/src/api/mod.rs b/src/api/mod.rs index d0d6905..9f78f1f 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1,8 +1,4 @@ -use axum::{ - extract::DefaultBodyLimit, - routing::{get, post}, - Router, -}; +use axum::{extract::DefaultBodyLimit, routing::get, Router}; use tower_http::{limit::RequestBodyLimitLayer, trace::TraceLayer}; pub mod invoices; @@ -10,8 +6,7 @@ pub mod invoices; pub fn app() -> Router { Router::new() .route("/health", get(health)) - .route("/invoices", post(invoices::create)) - .route("/invoices", get(invoices::list_all)) + .route("/invoices", get(invoices::list_all).post(invoices::create)) .layer(TraceLayer::new_for_http()) .layer(DefaultBodyLimit::disable()) .layer(RequestBodyLimitLayer::new(