From 4b6cb12f2b3cfcf2b0d5b982f79f126fc2bf2720 Mon Sep 17 00:00:00 2001 From: Yader Velasquez Date: Thu, 8 Dec 2022 19:29:21 -0600 Subject: [PATCH] Support dynamic url based on Service settings --- feedback.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/feedback.go b/feedback.go index dfdc1f1..4492e17 100644 --- a/feedback.go +++ b/feedback.go @@ -20,9 +20,6 @@ import ( var hostPattern = regexp.MustCompile(`^sns\.[a-zA-Z0-9\-]{3,}\.amazonaws\.com(\.cn)?$`) -// FeedbackURL is the url to call the feedback handler -var FeedbackURL string = "/ses-feedback" - // Actions ... type Actions interface { Bounce(data map[string]any) error @@ -42,11 +39,12 @@ type Service struct { eg *echo.Group actions Actions verify bool + url string } // RegisterRoutes ... func (s *Service) RegisterRoutes() { - s.eg.POST(FeedbackURL, s.Feedback).Name = s.RouteName("feedback") + s.eg.POST(s.url, s.Feedback).Name = s.RouteName("endpoint") } // RouteName ... @@ -215,8 +213,17 @@ func (s *Service) Feedback(c echo.Context) error { } // NewService ... -func NewService(eg *echo.Group, ac Actions, verify bool) *Service { - service := &Service{name: "ses-feedback", eg: eg, actions: ac, verify: verify} +func NewService(eg *echo.Group, ac Actions, verify bool, url string) *Service { + if url == "" { + url = "/ses-feedback" + } + service := &Service{ + name: "ses-feedback", + eg: eg, + actions: ac, + verify: verify, + url: url, + } service.RegisterRoutes() return service } -- 2.45.2