From 8582674b44aaddd2e5f6cdf8e1328bc97f1f2fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Tue, 20 Dec 2022 13:55:09 +0100 Subject: [PATCH] Refactoring --- server/{common => api}/ginext/cors.go | 0 server/{common => api}/ginext/gin.go | 0 server/{common => api}/ginext/handler.go | 0 server/{common => api}/ginresp/apiError.go | 0 server/{common => api}/ginresp/resp.go | 0 server/{common => api}/ginresp/wrapper.go | 0 server/api/handler/api.go | 2 +- server/api/handler/common.go | 2 +- server/api/handler/compat.go | 2 +- server/api/handler/message.go | 2 +- server/api/handler/website.go | 2 +- server/api/router.go | 4 ++-- server/cmd/scnserver/main.go | 5 ++--- server/{common => }/init.go | 5 ++--- server/logic/appcontext.go | 2 +- server/logic/application.go | 2 +- server/logic/permissions.go | 2 +- server/swagger/swagger.go | 2 +- server/test/util/log.go | 2 +- server/test/util/webserver.go | 2 +- 20 files changed, 17 insertions(+), 19 deletions(-) rename server/{common => api}/ginext/cors.go (100%) rename server/{common => api}/ginext/gin.go (100%) rename server/{common => api}/ginext/handler.go (100%) rename server/{common => api}/ginresp/apiError.go (100%) rename server/{common => api}/ginresp/resp.go (100%) rename server/{common => api}/ginresp/wrapper.go (100%) rename server/{common => }/init.go (85%) diff --git a/server/common/ginext/cors.go b/server/api/ginext/cors.go similarity index 100% rename from server/common/ginext/cors.go rename to server/api/ginext/cors.go diff --git a/server/common/ginext/gin.go b/server/api/ginext/gin.go similarity index 100% rename from server/common/ginext/gin.go rename to server/api/ginext/gin.go diff --git a/server/common/ginext/handler.go b/server/api/ginext/handler.go similarity index 100% rename from server/common/ginext/handler.go rename to server/api/ginext/handler.go diff --git a/server/common/ginresp/apiError.go b/server/api/ginresp/apiError.go similarity index 100% rename from server/common/ginresp/apiError.go rename to server/api/ginresp/apiError.go diff --git a/server/common/ginresp/resp.go b/server/api/ginresp/resp.go similarity index 100% rename from server/common/ginresp/resp.go rename to server/api/ginresp/resp.go diff --git a/server/common/ginresp/wrapper.go b/server/api/ginresp/wrapper.go similarity index 100% rename from server/common/ginresp/wrapper.go rename to server/api/ginresp/wrapper.go diff --git a/server/api/handler/api.go b/server/api/handler/api.go index afb23d1..8309c23 100644 --- a/server/api/handler/api.go +++ b/server/api/handler/api.go @@ -3,7 +3,7 @@ package handler import ( "blackforestbytes.com/simplecloudnotifier/api/apierr" hl "blackforestbytes.com/simplecloudnotifier/api/apihighlight" - "blackforestbytes.com/simplecloudnotifier/common/ginresp" + "blackforestbytes.com/simplecloudnotifier/api/ginresp" "blackforestbytes.com/simplecloudnotifier/db" "blackforestbytes.com/simplecloudnotifier/db/cursortoken" "blackforestbytes.com/simplecloudnotifier/logic" diff --git a/server/api/handler/common.go b/server/api/handler/common.go index 071d44f..d663a27 100644 --- a/server/api/handler/common.go +++ b/server/api/handler/common.go @@ -2,7 +2,7 @@ package handler import ( "blackforestbytes.com/simplecloudnotifier/api/apierr" - "blackforestbytes.com/simplecloudnotifier/common/ginresp" + "blackforestbytes.com/simplecloudnotifier/api/ginresp" "blackforestbytes.com/simplecloudnotifier/logic" "bytes" "context" diff --git a/server/api/handler/compat.go b/server/api/handler/compat.go index 16dd08f..accd0ea 100644 --- a/server/api/handler/compat.go +++ b/server/api/handler/compat.go @@ -1,7 +1,7 @@ package handler import ( - "blackforestbytes.com/simplecloudnotifier/common/ginresp" + "blackforestbytes.com/simplecloudnotifier/api/ginresp" "blackforestbytes.com/simplecloudnotifier/db" "blackforestbytes.com/simplecloudnotifier/logic" "blackforestbytes.com/simplecloudnotifier/models" diff --git a/server/api/handler/message.go b/server/api/handler/message.go index 0e6f79a..7a92ede 100644 --- a/server/api/handler/message.go +++ b/server/api/handler/message.go @@ -3,7 +3,7 @@ package handler import ( "blackforestbytes.com/simplecloudnotifier/api/apierr" hl "blackforestbytes.com/simplecloudnotifier/api/apihighlight" - "blackforestbytes.com/simplecloudnotifier/common/ginresp" + "blackforestbytes.com/simplecloudnotifier/api/ginresp" "blackforestbytes.com/simplecloudnotifier/db" "blackforestbytes.com/simplecloudnotifier/logic" "blackforestbytes.com/simplecloudnotifier/models" diff --git a/server/api/handler/website.go b/server/api/handler/website.go index 4e0b610..d0e15d4 100644 --- a/server/api/handler/website.go +++ b/server/api/handler/website.go @@ -1,7 +1,7 @@ package handler import ( - "blackforestbytes.com/simplecloudnotifier/common/ginresp" + "blackforestbytes.com/simplecloudnotifier/api/ginresp" "blackforestbytes.com/simplecloudnotifier/logic" "blackforestbytes.com/simplecloudnotifier/website" "errors" diff --git a/server/api/router.go b/server/api/router.go index 7fa9f00..3443436 100644 --- a/server/api/router.go +++ b/server/api/router.go @@ -1,9 +1,9 @@ package api import ( + "blackforestbytes.com/simplecloudnotifier/api/ginext" + "blackforestbytes.com/simplecloudnotifier/api/ginresp" "blackforestbytes.com/simplecloudnotifier/api/handler" - "blackforestbytes.com/simplecloudnotifier/common/ginext" - "blackforestbytes.com/simplecloudnotifier/common/ginresp" "blackforestbytes.com/simplecloudnotifier/logic" "blackforestbytes.com/simplecloudnotifier/swagger" "github.com/gin-gonic/gin" diff --git a/server/cmd/scnserver/main.go b/server/cmd/scnserver/main.go index 3d86053..854e731 100644 --- a/server/cmd/scnserver/main.go +++ b/server/cmd/scnserver/main.go @@ -3,8 +3,7 @@ package main import ( scn "blackforestbytes.com/simplecloudnotifier" "blackforestbytes.com/simplecloudnotifier/api" - "blackforestbytes.com/simplecloudnotifier/common" - "blackforestbytes.com/simplecloudnotifier/common/ginext" + "blackforestbytes.com/simplecloudnotifier/api/ginext" "blackforestbytes.com/simplecloudnotifier/db" "blackforestbytes.com/simplecloudnotifier/google" "blackforestbytes.com/simplecloudnotifier/jobs" @@ -17,7 +16,7 @@ import ( var conf = scn.Conf func main() { - common.Init(conf) + scn.Init(conf) log.Info().Msg(fmt.Sprintf("Starting with config-namespace <%s>", conf.Namespace)) diff --git a/server/common/init.go b/server/init.go similarity index 85% rename from server/common/init.go rename to server/init.go index 5ba8bba..bbfb4bb 100644 --- a/server/common/init.go +++ b/server/init.go @@ -1,14 +1,13 @@ -package common +package server import ( - scn "blackforestbytes.com/simplecloudnotifier" "github.com/gin-gonic/gin" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "os" ) -func Init(cfg scn.Config) { +func Init(cfg Config) { cw := zerolog.ConsoleWriter{ Out: os.Stdout, TimeFormat: "2006-01-02 15:04:05 Z07:00", diff --git a/server/logic/appcontext.go b/server/logic/appcontext.go index 5ed4f23..295d1ee 100644 --- a/server/logic/appcontext.go +++ b/server/logic/appcontext.go @@ -2,7 +2,7 @@ package logic import ( "blackforestbytes.com/simplecloudnotifier/api/apierr" - "blackforestbytes.com/simplecloudnotifier/common/ginresp" + "blackforestbytes.com/simplecloudnotifier/api/ginresp" "blackforestbytes.com/simplecloudnotifier/db" "context" "errors" diff --git a/server/logic/application.go b/server/logic/application.go index 4f622b4..ff61f15 100644 --- a/server/logic/application.go +++ b/server/logic/application.go @@ -3,7 +3,7 @@ package logic import ( scn "blackforestbytes.com/simplecloudnotifier" "blackforestbytes.com/simplecloudnotifier/api/apierr" - "blackforestbytes.com/simplecloudnotifier/common/ginresp" + "blackforestbytes.com/simplecloudnotifier/api/ginresp" "blackforestbytes.com/simplecloudnotifier/db" "blackforestbytes.com/simplecloudnotifier/google" "blackforestbytes.com/simplecloudnotifier/models" diff --git a/server/logic/permissions.go b/server/logic/permissions.go index cc549b0..e86e68f 100644 --- a/server/logic/permissions.go +++ b/server/logic/permissions.go @@ -2,7 +2,7 @@ package logic import ( "blackforestbytes.com/simplecloudnotifier/api/apierr" - "blackforestbytes.com/simplecloudnotifier/common/ginresp" + "blackforestbytes.com/simplecloudnotifier/api/ginresp" "blackforestbytes.com/simplecloudnotifier/models" "gogs.mikescher.com/BlackForestBytes/goext/langext" ) diff --git a/server/swagger/swagger.go b/server/swagger/swagger.go index 5b153f8..816ecb7 100644 --- a/server/swagger/swagger.go +++ b/server/swagger/swagger.go @@ -1,7 +1,7 @@ package swagger import ( - "blackforestbytes.com/simplecloudnotifier/common/ginresp" + "blackforestbytes.com/simplecloudnotifier/api/ginresp" "embed" _ "embed" "github.com/gin-gonic/gin" diff --git a/server/test/util/log.go b/server/test/util/log.go index 68faa55..a84cd11 100644 --- a/server/test/util/log.go +++ b/server/test/util/log.go @@ -1,7 +1,7 @@ package util import ( - "blackforestbytes.com/simplecloudnotifier/common/ginext" + "blackforestbytes.com/simplecloudnotifier/api/ginext" "fmt" "github.com/gin-gonic/gin" "github.com/rs/zerolog/log" diff --git a/server/test/util/webserver.go b/server/test/util/webserver.go index 1a9e534..bcd47aa 100644 --- a/server/test/util/webserver.go +++ b/server/test/util/webserver.go @@ -3,7 +3,7 @@ package util import ( scn "blackforestbytes.com/simplecloudnotifier" "blackforestbytes.com/simplecloudnotifier/api" - "blackforestbytes.com/simplecloudnotifier/common/ginext" + "blackforestbytes.com/simplecloudnotifier/api/ginext" "blackforestbytes.com/simplecloudnotifier/db" "blackforestbytes.com/simplecloudnotifier/google" "blackforestbytes.com/simplecloudnotifier/jobs"