From 6789c4f550fa98468bdc21b007d3866c661023b4 Mon Sep 17 00:00:00 2001 From: lash Date: Sun, 5 Jan 2025 11:17:58 +0000 Subject: [PATCH] Export handlers --- cmd/async/main.go | 2 +- cmd/http/main.go | 2 +- cmd/main.go | 2 +- {internal/handlers => handlers}/base.go | 10 ++++++++-- .../handlers/handlerservice.go => handlers/local.go | 0 internal/handlers/single.go | 1 - internal/testutil/engine.go | 2 +- 7 files changed, 12 insertions(+), 7 deletions(-) rename {internal/handlers => handlers}/base.go (93%) rename internal/handlers/handlerservice.go => handlers/local.go (100%) diff --git a/cmd/async/main.go b/cmd/async/main.go index 1e06029..47d7901 100644 --- a/cmd/async/main.go +++ b/cmd/async/main.go @@ -15,7 +15,7 @@ import ( "git.grassecon.net/urdt/ussd/config" "git.grassecon.net/urdt/ussd/initializers" - "git.grassecon.net/urdt/ussd/internal/handlers" + "git.grassecon.net/urdt/ussd/handlers" "git.grassecon.net/urdt/ussd/internal/storage" "git.grassecon.net/urdt/ussd/remote" "git.grassecon.net/urdt/ussd/request" diff --git a/cmd/http/main.go b/cmd/http/main.go index eb2aa19..5112aca 100644 --- a/cmd/http/main.go +++ b/cmd/http/main.go @@ -17,7 +17,7 @@ import ( "git.grassecon.net/urdt/ussd/config" "git.grassecon.net/urdt/ussd/initializers" - "git.grassecon.net/urdt/ussd/internal/handlers" + "git.grassecon.net/urdt/ussd/handlers" httpserver "git.grassecon.net/urdt/ussd/internal/http" "git.grassecon.net/urdt/ussd/internal/storage" "git.grassecon.net/urdt/ussd/remote" diff --git a/cmd/main.go b/cmd/main.go index ac680fc..2e4eff0 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -11,8 +11,8 @@ import ( "git.defalsify.org/vise.git/logging" "git.defalsify.org/vise.git/resource" "git.grassecon.net/urdt/ussd/config" + "git.grassecon.net/urdt/ussd/handlers" "git.grassecon.net/urdt/ussd/initializers" - "git.grassecon.net/urdt/ussd/internal/handlers" "git.grassecon.net/urdt/ussd/internal/storage" "git.grassecon.net/urdt/ussd/remote" ) diff --git a/internal/handlers/base.go b/handlers/base.go similarity index 93% rename from internal/handlers/base.go rename to handlers/base.go index ed3d63d..6595a60 100644 --- a/internal/handlers/base.go +++ b/handlers/base.go @@ -5,12 +5,18 @@ import ( "git.defalsify.org/vise.git/engine" "git.defalsify.org/vise.git/persist" "git.defalsify.org/vise.git/resource" + "git.defalsify.org/vise.git/logging" "git.grassecon.net/urdt/ussd/request" + "git.grassecon.net/urdt/ussd/errors" "git.grassecon.net/urdt/ussd/internal/handlers/ussd" "git.grassecon.net/urdt/ussd/internal/storage" ) +var ( + logg = logging.NewVanilla().WithDomain("handlers") +) + type BaseSessionHandler struct { cfgTemplate engine.Config rp request.RequestParser @@ -52,7 +58,7 @@ func(f *BaseSessionHandler) Process(rqs request.RequestSession) (request.Request rqs.Storage, err = f.provider.Get(rqs.Config.SessionId) if err != nil { logg.ErrorCtxf(rqs.Ctx, "", "storage get error", err) - return rqs, ErrStorage + return rqs, errors.ErrStorage } f.hn = f.hn.WithPersister(rqs.Storage.Persister) @@ -67,7 +73,7 @@ func(f *BaseSessionHandler) Process(rqs request.RequestSession) (request.Request if perr != nil { logg.ErrorCtxf(rqs.Ctx, "", "storage put error", perr) } - return rqs, ErrEngineType + return rqs, errors.ErrEngineType } en = en.WithFirst(f.hn.Init) if rqs.Config.EngineDebug { diff --git a/internal/handlers/handlerservice.go b/handlers/local.go similarity index 100% rename from internal/handlers/handlerservice.go rename to handlers/local.go diff --git a/internal/handlers/single.go b/internal/handlers/single.go index 19079dd..b178399 100644 --- a/internal/handlers/single.go +++ b/internal/handlers/single.go @@ -19,4 +19,3 @@ var ( var ( logg = logging.NewVanilla().WithDomain("handlers") ) - diff --git a/internal/testutil/engine.go b/internal/testutil/engine.go index 2372ce9..57f2b7c 100644 --- a/internal/testutil/engine.go +++ b/internal/testutil/engine.go @@ -11,7 +11,7 @@ import ( "git.defalsify.org/vise.git/engine" "git.defalsify.org/vise.git/logging" "git.defalsify.org/vise.git/resource" - "git.grassecon.net/urdt/ussd/internal/handlers" + "git.grassecon.net/urdt/ussd/handlers" "git.grassecon.net/urdt/ussd/internal/storage" "git.grassecon.net/urdt/ussd/internal/testutil/testservice" "git.grassecon.net/urdt/ussd/internal/testutil/testtag"