From d95f4dc51f3e4b764f76da064b8f5b16a4e8cee8 Mon Sep 17 00:00:00 2001 From: Dumindu Madunuwan Date: Sat, 20 Jan 2024 22:22:20 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A0=20Move=20requestlog=20into=20middl?= =?UTF-8?q?eware?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 32 +++++++++++-------- .../middleware}/requestlog/handler.go | 0 .../middleware}/requestlog/log_entry.go | 0 api/router/router.go | 2 +- 4 files changed, 20 insertions(+), 14 deletions(-) rename api/{ => router/middleware}/requestlog/handler.go (100%) rename api/{ => router/middleware}/requestlog/log_entry.go (100%) diff --git a/README.md b/README.md index ac9e821..9d0a1ca 100644 --- a/README.md +++ b/README.md @@ -59,20 +59,26 @@ myapp │ └── main.go │ ├── api -│ ├── router -│ │ └── router.go +│ ├── resource +│ │ ├── book +│ │ │ ├── handler.go +│ │ │ ├── model.go +│ │ │ ├── repository.go +│ │ │ └── repository_test.go +│ │ ├── common +│ │ │ └── err +│ │ │ └── err.go +│ │ └── health +│ │ └── handler.go │ │ -│ └── resource -│ ├── health -│ │ └── handler.go -│ ├── book -│ │ ├── api.go -│ │ ├── handler.go -│ │ ├── model.go -│ │ └── repository.go -│ └── common -│ └── err -│ └── err.go +│ └── router +│ ├── middleware +│ │ ├── content_type_json.go +│ │ ├── content_type_json_test.go +│ │ └── requestlog +│ │ ├── handler.go +│ │ └── log_entry.go +│ └── router.go │ ├── migrations │ └── 00001_create_books_table.sql diff --git a/api/requestlog/handler.go b/api/router/middleware/requestlog/handler.go similarity index 100% rename from api/requestlog/handler.go rename to api/router/middleware/requestlog/handler.go diff --git a/api/requestlog/log_entry.go b/api/router/middleware/requestlog/log_entry.go similarity index 100% rename from api/requestlog/log_entry.go rename to api/router/middleware/requestlog/log_entry.go diff --git a/api/router/router.go b/api/router/router.go index 6a7a623..57798f7 100644 --- a/api/router/router.go +++ b/api/router/router.go @@ -6,10 +6,10 @@ import ( "github.com/rs/zerolog" "gorm.io/gorm" - "myapp/api/requestlog" "myapp/api/resource/book" "myapp/api/resource/health" "myapp/api/router/middleware" + "myapp/api/router/middleware/requestlog" ) func New(l *zerolog.Logger, v *validator.Validate, db *gorm.DB) *chi.Mux {